function onAsToJs(para) {
    $(window).trigger("onAsToJs", para);//抛出事件
}
function onJsToAs(para) {
    $('#player_socket')[0].onJsToAs(para);//调用Flash事件
    $('#FlyScreenSwf')[0].onJsToAs(para);//飞屏Flash事件
    $('#StreamerEffect')[0].onJsToAs(para);//飞屏Flash事件
}
String.prototype.replaceAll = function(s1,s2){
    return this.split(s1).join(s2);
}

$(function(){
    var Log = {
        Out:function (label, str) {
            // return;
            if(str){
                console.log(label, str);
                return;
            }
            console.log(label);
        }
    };

    var _ThisPage = {
        Flash:{
            Data: {
                isInit: false, //Flash是否已初始化
                isPlay: false, //Join触发,Flash还未初始化，成功时，此值为Falsh
                isPlayData: {},//临时存储的值
                Event: []//调用函数 事件
            },
            AsToJs:function (event, para) {
                if (para.type == "flash_init") {
                    //Flash初始化
                    _ThisPage.Flash.Init();
                } else if (para.type == "EffectSwitch") {
                    //Flash效果开关 按钮事件
                    _ThisPage.Page.Gift.Data.isEffectOn = para.isOpen;
                } else if (para.type == "StartLive") {
                    //Flash开始直播 按钮事件
                    // _SocketIO.emit('Live');
                    // _ThisPage.RobotManage.SetShowStatus(true);
                    $.CommonMainRoom.SocketEmit.Live();
                } else if (para.type == "EndLive") {
                    //Flash结束直播 按钮事件
                    // _SocketIO.emit('LiveEnd');
                    // _ThisPage.RobotManage.SetShowStatus(false);
                    $.CommonMainRoom.SocketEmit.LiveEnd();
                }else if(para.type == "change_anchor"){
                    //换一换 艺人
                }else if(para.type == "login"){
                    if(para.act == "qq_btn"){
                        window.open(_VirtualPath.Main + 'oauth/qqconnect.tologin',"TencentLogin","width=450,height=320,menubar=0,scrollbars=1,resizable=1,status=1,titlebar=0,toolbar=0,location=1");
                    }else if(para.act == "weibo_btn"){
                        window.open(_VirtualPath.Main + 'oauth/weibo.tologin',"TencentLogin","width=450,height=320,menubar=0,scrollbars=1,resizable=1,status=1,titlebar=0,toolbar=0,location=1");
                    }else if(para.act == "xiyou_btn"){
                        $.CommonMain.Login('In');
                    }
                }else if(para.type == "network_speed"){
                    //万根网络数据提交
                    var msgData = "fps="+para.data.currentFPS+"&" +
                        "uri="+para.data.uri+"&" +
                        "time="+para.data.time+"&" +
                        "videoBufferLength="+para.data.videoBufferLength+"&" +
                        "videoBufferByteLength="+para.data.videoBufferByteLength+"&" +
                        "videoWidth="+para.data.videoWidth+"&" +
                        "videoHeight="+para.data.videoHeight;
                    _ThisPage.Page.Flash.WanGen.submit_http_err(msgData);
                    Log.Out("newwork_speed = ", [para.data, msgData]);
                }else if(para.type == "flyscreen_init"){
                    onJsToAs({type: "flyscreen_setPath", data:_VirtualPath }); //初始化飞屏参数，用到，静态服务器路径
                    Log.Out("flyscreen_init");
                }else if(para.type == "streamer_init"){
                    onJsToAs({type: "streamer_setPath", data:_VirtualPath.Static }); //初始化飞屏参数，用到，静态服务器路径
                    Log.Out("streamer_init"); //流光初始化
                }
            },
            //初始化
            Init: function () {
                this.Data.isInit = true;
                Log.Out("FlashInit");
                if (_ThisPage.Flash.Data.Event.length > 0) {
                    for (var i = 0; i < _ThisPage.Flash.Data.Event.length; i++) {
                        var event = _ThisPage.Flash.Data.Event[i];
                        _ThisPage.Flash[event.type](event.data);
                    }
                    _ThisPage.Flash.Data.Event = [];
                }
            },
            //进入房后 通知flash
            JoinRoom: function (data) {
                if (_ThisPage.Flash.Data.isInit) {
                    var userType = (_StateData.IsLogin) ? ($.CommonMainRoom.RoomUserInfo.RoomAnchor ? 1 : 2) : 3;
                    //让Flash显示 艺人或用户 界面
                    onJsToAs({type: "IsAnchor", userType: userType});
                    if (data.Live){
                        _ThisPage.Flash.PlayVideo(data);//进房成功后 是否正在直播
                    }else{
                        _ThisPage.Flash.EndLive();//有可能断线后，重联，将直播状态，断开。
                    }
                } else {
                    _ThisPage.Flash.Data.Event.push({type: "JoinRoom", data: data});
                }
            },
            //播放视频
            PlayVideo: function (data) {
                if(!this.Data.isInit) return;
                if (_ThisPage.Flash.Data.isInit) {
                    onJsToAs({type: "PlayVideo", rtmpUrl: data.Live_URL});
                } else {
                    _ThisPage.Flash.Data.isPlay = true;
                    _ThisPage.Flash.Data.isPlayData = data;
                }
            },
            //发布视频
            PublishVideo: function (data) {
                if(!this.Data.isInit) return;
                onJsToAs({type: "PublishVideo", rtmpUrl: data.Live_PUSH});
            },
            //结束直播
            EndLive: function () {
                if(!this.Data.isInit) return;
                onJsToAs({type: "EndLive"});
            },
            //万根 流媒体 数据 追踪
            WanGen:{
                param : {
                    'url': '',
                    'speed': 0,
                    'code': 0,
                    'msg': 'test',
                    'serverip': '1.1.1.1',
                    'method_str': 'GET',
                    'ldns':'',
                    'c_dns_ip':'',
                    'ret_format': 'jsonp'
                },
                rnd:function(){
                    _ThisPage.Flash.WanGen.rnd.seed = (_ThisPage.Flash.WanGen.rnd.seed * 9301 + 49297) % 233280;
                    return _ThisPage.Flash.WanGen.rnd.seed / (233280.0);
                },
                rand:function(number){
                    return Math.ceil(_ThisPage.Flash.WanGen.rnd() * number);
                },
                submit_http_err:function (msgData) {
                    var rnd = _ThisPage.Flash.WanGen.rnd;
                    rnd.today = new Date();
                    rnd.seed = rnd.today.getTime();

                    var param = _ThisPage.Flash.WanGen.param;
                    param.url = encodeURI(window.document.location);
                    param.msg = msgData;
                    param.ldns = Math.ceil(rnd() * 10000000000000000);

                    var url = 'http://' + param.ldns + '.testns.cdnunion.net';

                    $.getJSON(url + '?callback=?',function(ret) {
                        param['c_dns_ip'] = ret['dns']['ip'];  // 本地DNS查询结果
                        _ThisPage.Flash.WanGen.send_http_err(); // 第一步异步返回后调用第二步
                    });
                },
                send_http_err:function () {
                    $.getJSON('http://cs.vangen.cn/interface/http_err.php' + '?callback=?', _Flash.WanGen.param, function(ret){
                        console.dir(ret);
                    }, 'json');
                }
            }
        },
        Page:{
            //页面初始化就执行
            Init:function () {
                //监听Flash传回到页面上的事件
                $(window).off("onAsToJs");
                $(window).on("onAsToJs", _ThisPage.Flash.AsToJs);
                //加载 礼物特效 坐标组合形状 配置文件
                GiftEffectFactory.LoadConfigFile(_VirtualPath.Static+"main/js/room.config.effect.json");
                //加载昵称列表
                _ThisPage.Page.RobotManage.LoadNicknameFile(_VirtualPath.Static+"main/js/room.userlist.nickname.txt");
                //初始化隐藏元件
                $("#J_GiftSendBtnProgress").hide();
                $("#J_GiftSendBtnProgressNum").hide();
                $("#J_GiftSendBtnProgressText").show();
                $(".GiftBuyPanel").hide();
                $("#J_MNickNameUI2").hide();
                $("#J_PomeloTime").hide();

                //左侧导航 显示登录按钮 或 自己信息
                if (_StateData.IsLogin) {
                    $("#J_CheckLoginBtn").hide();
                    $("#J_MiniUserCard").show();
                } else {
                    $("#J_CheckLoginBtn").show();
                    $("#J_MiniUserCard").hide();
                }
                //排行榜初始化
                _ThisPage.Page.Ranking.Init();
                //用户信息面板(操作功能)初始化
                _ThisPage.Page.CommonUitls.InitUserInfoPanel();
                //金币不够，提示充值面板
                _ThisPage.Page.CommonUitls.PayBoxPanel.Init();
                //用户列表初始化
                _ThisPage.Page.UserList.Init();
                //举报按钮事件
                $("#J_Room_Report").on("click",function () {
                    if (!$.CommonMain.LoginCheck()) {
                        return;
                    }
                    $(this).attr( {"OpenWindow":":AnchorLiveReport:"+$.CommonMainRoom.RoomInfo.RoomID} );
                });
                //转盘抽奖
                _ThisPage.Page.Game.Lottery();
            },
            //进房成功
            JoinComplete:function (data) {
                //星星初始化
                _ThisPage.Page.PomeloUtil.Init(data.RoomUserInfo);
                //初始化分享数据
                _ThisPage.Page.Share.Init();
                //聊天功能初始化
                _ThisPage.Page.Chat.Init(data);
                //房间初始化
                _ThisPage.Page.Room.Init(data);
                //初始化自己用户卡片
                _ThisPage.Page.Self.Init(data);
                //艺人相关初始化
                _ThisPage.Page.Anchor.Init();
                //礼物功能初始化
                _ThisPage.Page.Gift.Init();
                //守护功能初始化
                _ThisPage.Page.Guardian.Init(data);
                //飞屏喇叭初始化
                _ThisPage.Page.FlyScreen.Init();
                _ThisPage.Page.Horn.Init();
                //用户列表
                _ThisPage.Page.UserList.LoadList();
                //管理员列表
                _ThisPage.Page.UserList.Admin.LoadList();
                //视频区初始化
                _ThisPage.Page.Video.Init();
                //冻结功能
                _ThisPage.Page.CommonUitls.FrozenRoom.Init();
                //用户包裹数据
                Log.Out("UserPackage", $.CommonMainRoom.UserPackage);
                //机器人初始化
                // _ThisPage.Page.RobotManage.SetInit( Math.ceil(data.Anchor_Level / 5 + 1) * 100 , data.Live);
                //任务列表
                _ThisPage.Page.TaskList.Init();
                //测试升级 提示
                // _ThisPage.Page.UserLevelUpgrade.Test.Init();
                //修改 切换 CDN
                // setTimeout(function(){
                //     if($.CommonMainRoom.RoomUserInfo.RoomAnchor){
                //         $.CommonMainRoom.SocketEmit.ChangeCDN({CDNIndex:7});
                //     }
                // }, 5000);
                //跑道初始化
                _ThisPage.Page.Runway.Init();
            },
            /**
             * 公共数据
             */
            CommonData:{

            },
            /**
             * 公共方法
             */
            CommonUitls:{
                //获取用户头像
                GetUserHand:function (User_ID, Size) {
                    Size = (Size) ? Size : "54.54";
                    return $.Common.ImageBind.UserAvatar.fnURL(User_ID, Size);
                },
                //获取艺人头像
                GetAvatarHand:function (User_ID, Size) {
                    Size = (Size) ? Size : "80.80";
                    return $.Common.ImageBind.UserCover.fnURL(User_ID, Size);
                },
                //用户信息面板(操作功能)初始化
                InitUserInfoPanel: function () {
                    //弹出用户卡片
                    $("#J_Chatlistinfo,#J_ChatlistinfoPrivate").off('click');
                    $("#J_Chatlistinfo,#J_ChatlistinfoPrivate").on('click', 'span[data-uid]', function (event) {
                        if (!$.CommonMain.LoginCheck()) {
                            return;
                        }
                        var data = $(this).data('userdata');
                        if (!data) {
                            return
                        }
                        var _left = $(this).offset().left - ($(this).width());
                        var _top = $(this).offset().top + $(this).height() + 8;
                        $("#J_UserCardPop").data('userinfo', data);
                        $("#J_UserCardPop").css({
                            left: _left,
                            top: _top
                        }).fadeIn();
                        _ThisPage.Page.CommonUitls.CreateUserInfoMiniCard(data);
                    });

                    //关闭用户卡片
                    $("#J_UserCardPop").off('mouseleave');
                    $("#J_UserCardPop").on('mouseleave', function (event) {
                        $("#J_UserCardPop").fadeOut(200);
                    });

                    //赠送 to ...
                    $("#J_UserCardPop").off('click', 'a[data-type=1]');
                    $("#J_UserCardPop").on('click', 'a[data-type=1]', function (event) {
                        var UserInfo = $(this).parents('#J_UserCardPop').data('userinfo');
                        Log.Out("菜单 赠送礼物", UserInfo);
                        _ThisPage.Page.Gift.AddGiftReceiveUserList(UserInfo);
                    });

                    //踢人
                    $("#J_UserCardPop").off('click', 'a[data-type=2]');
                    $("#J_UserCardPop").on('click', 'a[data-type=2]', function (event) {
                        var UserInfo = $(this).parents('#J_UserCardPop').data('userinfo');
                        var type = 2;//4 取消
                        $.CommonMainRoom.SocketEmit.BlackSet(UserInfo.User_ID, type, "MINUTE", 5);
                        Log.Out("踢出房间", UserInfo);
                    });
                    $("#J_UserCardPop").off('click', 'a[data-type=21]');
                    $("#J_UserCardPop").on('click', 'a[data-type=21]', function (event) {
                        var UserInfo = $(this).parents('#J_UserCardPop').data('userinfo');
                        var type = 4;
                        $.CommonMainRoom.SocketEmit.BlackSet(UserInfo.User_ID, type, "MINUTE", 5);
                        Log.Out("恢复进房", UserInfo);
                    });

                    //禁言
                    $("#J_UserCardPop").off('click', 'a[data-type=4]');
                    $("#J_UserCardPop").on('click', 'a[data-type=4]', function (event) {
                        var UserInfo = $(this).parents('#J_UserCardPop').data('userinfo');
                        var type = 1 ;
                        $.CommonMainRoom.SocketEmit.BlackSet(UserInfo.User_ID, type, "MINUTE", 5);
                        Log.Out("设置禁言", UserInfo);
                    });
                    $("#J_UserCardPop").off('click', 'a[data-type=41]');
                    $("#J_UserCardPop").on('click', 'a[data-type=41]', function (event) {
                        var UserInfo = $(this).parents('#J_UserCardPop').data('userinfo');
                        var type = 3;
                        $.CommonMainRoom.SocketEmit.BlackSet(UserInfo.User_ID, type, "MINUTE", 5);
                        Log.Out("解除禁言", UserInfo);
                    });

                    //提升管理
                    $("#J_UserCardPop").off('click', 'a[data-type=5]');
                    $("#J_UserCardPop").on('click', 'a[data-type=5]', function (event) {
                        var UserInfo = $(this).parents('#J_UserCardPop').data('userinfo');
                        var type = true ;
                        $.CommonMainRoom.SocketEmit.AdminSet(UserInfo.User_ID, type);
                        Log.Out("提升管理", UserInfo);
                    });
                    $("#J_UserCardPop").off('click', 'a[data-type=51]');
                    $("#J_UserCardPop").on('click', 'a[data-type=51]', function (event) {
                        var UserInfo = $(this).parents('#J_UserCardPop').data('userinfo');
                        var type = false;
                        $.CommonMainRoom.SocketEmit.AdminSet(UserInfo.User_ID, type);
                        Log.Out("撤销管理", UserInfo);
                    });

                    //对Ta说
                    $("#J_UserCardPop").off('click', 'a[data-type=6]');
                    $("#J_UserCardPop").on('click', 'a[data-type=6]', function (event) {
                        _ThisPage.Page.Chat.ChatSelectTab(0);
                        var UserInfo = $(this).parents('#J_UserCardPop').data('userinfo');
                        _ThisPage.Page.Chat.Data.ChatUser.id = UserInfo.User_ID;
                        _ThisPage.Page.Chat.Data.ChatUser.Private = false;
                        _ThisPage.Page.Chat.Data.ChatUser.PrivateTa = true;
                        _ThisPage.Page.Chat.Data.ChatUser.Receiver = UserInfo;

                        $("#J_InputTextWord").attr("placeholder","@ 对 "+UserInfo.NickName+" 说");
                        $("#J_InputTextWord").after('<a href="javascript:;" class="PrivateCancel" id="J_PrivateCancel"></a>');
                        _ThisPage.Page.CommonUitls.PrivateCancel();
                    });
                    //私聊Ta
                    $("#J_UserCardPop").off('click', 'a[data-type=7]');
                    $("#J_UserCardPop").on('click', 'a[data-type=7]', function (event) {
                        var UserInfo = $(this).parents('#J_UserCardPop').data('userinfo');
                        _ThisPage.Page.Chat.Data.ChatUser.id = UserInfo.User_ID;
                        _ThisPage.Page.Chat.Data.ChatUser.Private = true;
                        _ThisPage.Page.Chat.Data.ChatUser.PrivateTa = true;
                        _ThisPage.Page.Chat.Data.ChatUser.Receiver = UserInfo;
                        //这里要 做判断权限 是否可以私聊
                        _ThisPage.Page.Chat.ChatSelectTab(1);
                        $("#J_InputTextWord").attr("placeholder","@ 对 "+UserInfo.NickName+" 悄悄说");
                        $("#J_InputTextWord").after('<a href="javascript:;" class="PrivateCancel" id="J_PrivateCancel"></a>');
                        _ThisPage.Page.CommonUitls.PrivateCancel();
                    });
                },
                //取消私聊，对Ta说
                PrivateCancel:function(){
                    $("#J_PrivateCancel").off("click");
                    $("#J_PrivateCancel").on("click",function () {
                            _ThisPage.Page.Chat.ChatSelectTab(0);
                            _ThisPage.Page.Chat.Data.ChatUser.Private = false;
                            _ThisPage.Page.Chat.Data.ChatUser.Receiver = null;
                            $("#J_PrivateCancel").remove();
                            $("#J_InputTextWord").attr("placeholder","双手打字，以示清白～");
                    });
                },
                //创建资料卡
                CreateUserInfoMiniCard: function (data) {
                    var _Path = data.RoomAnchor ? "anchor/" : "user/";
                    var _Level = data.RoomAnchor ? $.CommonMainRoom.RoomAnchorInfo.Level : data.Level;
                    var CardInfo = "";
                    CardInfo += '<div class="UserCardInfo">';
                    CardInfo +='<div class="MCard-Arrow"><div class="MCard-Arrowin"></div></div>';
                    CardInfo +='<div class="MCard-Info" id="J_MCard-Info">';
                    CardInfo += '<div class="CardInfo">';
                    CardInfo += '<div class="UserPic">';
                    CardInfo += '<img src="'+_ThisPage.Page.CommonUitls.GetUserHand(data.User_ID)+'" class="_thumb">';
                    CardInfo += '</div>';
                    CardInfo += '<div class="UserIntro">';
                    CardInfo += '<p class="level"><img src="' + _VirtualPath.Static + 'main/image/common/level/' + _Path + _Level + '.png" alt="' + _Level + '"></p>';
                    CardInfo += '<p class="name" id="J_UserCard_Name" alt="'+data.NickName+'">' + data.NickName + '</p>';
                    CardInfo += '</div>';
                    if(!data.Guest) CardInfo += '<div style="color:#FFF">ID:'+data.User_ID+'</div>';
                    CardInfo += '<div>'+_ThisPage.Page.Chat.CommonUtils.GetBadgeIconHtml(data.EmblemList)+'</div>';
                    CardInfo += '</div>';
                    CardInfo += '<div class="CardKit">';
                    // var adminText = data.RoomAdmin ? "撤消" : "提升";
                    // var banTalk = data.RoomBlack ? "解除禁言" : "禁言";
                    // if (data.User_ID != $.CommonMainRoom.RoomUserInfo.User_ID && $.CommonMainRoom.RoomUserInfo.RoomAnchor) { //我是艺人
                    //     CardInfo += '<ul class="KitList">';
                    //     CardInfo += '<li><a href="javascript:;" data-type="1">赠送礼物</a></li>';
                    //     CardInfo += '<li><a href="javascript:;" data-type="2">踢出房间</a></li>';
                    //     // CardInfo += '<li><a href="javascript:;" data-type="3">屏蔽此人</a></li>';
                    //     CardInfo += '<li><a href="javascript:;" data-type="4">'+banTalk+'</a></li>';
                    //     CardInfo += '<li><a href="javascript:;" data-type="5">'+adminText+'管理</a></li>';
                    //     CardInfo += '<li><a href="javascript:;" data-type="6">对Ta说</a></li>';
                    //     CardInfo += '<li><a href="javascript:;" data-type="7">私聊Ta</a></li>';
                    //     CardInfo += '</ul>';
                    // }
                    // else if (data.User_ID != $.CommonMainRoom.RoomUserInfo.User_ID && $.CommonMainRoom.RoomUserInfo.RoomAdmin) { //我是房管
                    //     CardInfo += '<ul class="KitList">';
                    //     CardInfo += '<li><a href="javascript:;" data-type="1">赠送礼物</a></li>';
                    //     if(!data.RoomAnchor){
                    //         CardInfo += '<li><a href="javascript:;" data-type="2">踢出房间</a></li>';
                    //         // CardInfo += '<li><a href="javascript:;" data-type="3">屏蔽此人</a></li>';
                    //         CardInfo += '<li><a href="javascript:;" data-type="4">禁言</a></li>';
                    //     }
                    //     CardInfo += '<li><a href="javascript:;" data-type="6">对Ta说</a></li>';
                    //     CardInfo += '<li><a href="javascript:;" data-type="7">私聊ta</a></li>';
                    //     CardInfo += '</ul>';
                    // }
                    // else if (data.User_ID != $.CommonMainRoom.RoomUserInfo.User_ID && !data.Guest) { //我是普通注册用户
                    //     CardInfo += '<ul class="KitList">';
                    //     CardInfo += '<li><a href="javascript:;" data-type="1">赠送礼物</a></li>';
                    //     // CardInfo += '<li><a href="javascript:;" data-type="3">屏蔽此人</a></li>';
                    //     CardInfo += '<li><a href="javascript:;" data-type="6">对Ta说</a></li>';
                    //     CardInfo += '<li><a href="javascript:;" data-type="7">私聊Ta</a></li>';
                    //     CardInfo += '</ul>';
                    // }
                    if(data.User_ID == $.CommonMainRoom.RoomUserInfo.User_ID || data.Guest){ //该菜单是 自己 或 游客 就显示此菜单
                        CardInfo += '<ul class="KitList">';
                        CardInfo += '</ul>';
                    }
                    else if(data.User_ID == $.CommonMainRoom.RoomAnchorInfo.RoomID){ //该菜单是 艺人
                        CardInfo += '<ul class="KitList">';
                        CardInfo += '<li><a href="javascript:;" data-type="1">赠送礼物</a></li>';
                        CardInfo += '<li><a href="javascript:;" data-type="11">　</a></li>';
                        CardInfo += '<li><a href="javascript:;" data-type="6">对Ta说</a></li>';
                        CardInfo += '<li><a href="javascript:;" data-type="7">私聊Ta</a></li>';
                        CardInfo += '</ul>';
                    }
                    else{
                        CardInfo += '<ul class="KitList">';
                        CardInfo += '<li><a href="javascript:;" data-type="1">赠送礼物</a></li>';
                        CardInfo += '<li><a href="javascript:;" data-type="11">　</a></li>';
                        CardInfo += '<li><a href="javascript:;" data-type="6">对Ta说</a></li>';
                        CardInfo += '<li><a href="javascript:;" data-type="7">私聊Ta</a></li>';
                        if($.CommonMainRoom.RoomUserInfo.RoomAnchor || $.CommonMainRoom.RoomUserInfo.RoomAdmin || $.CommonMainRoom.RoomUserInfo.IsAdmin){
                            CardInfo += '<li><a href="javascript:;" data-type="4">禁言</a></li>';
                            CardInfo += '<li><a href="javascript:;" data-type="41">解除禁言</a></li>';
                            CardInfo += '<li><a href="javascript:;" data-type="2">踢出房间</a></li>';
                            CardInfo += '<li><a href="javascript:;" data-type="21">恢复进房</a></li>';
                        }
                        if($.CommonMainRoom.RoomUserInfo.RoomAnchor){
                            CardInfo += '<li><a href="javascript:;" data-type="5">提升管理</a></li>';
                            CardInfo += '<li><a href="javascript:;" data-type="51">撤销管理</a></li>';
                        }
                        CardInfo += '</ul>';
                    }
                    CardInfo += '</div>';
                    CardInfo += '</div>';
                    CardInfo += '</div>';
                    $("#J_UserCardPop").html(CardInfo);
                },
                //用户 权限 被操作的提示
                UserRoleTip:function (data, Type) {
                    $.CommonMainRoom.RoomAnchorInfo.RoomAnchor = true;
                    var msg = {};
                    if(Type == "Admin"){
                        msg = { //设置禁言
                            User1:$.CommonMainRoom.RoomAnchorInfo,
                            User2:data.RoomUserInfo,
                            Text: (data.RoomUserInfo.RoomAdmin) ? '{User1} 将 {User2} 设置成管理员。' : '{User1} 将 {User2} 撤销管理员。'
                        };
                        if(msg.User2){
                            _ThisPage.Page.Chat.OutText(msg);
                        }
                    }else if(Type == "Black"){
                        // if(data.Type == 2){ //踢出房间
                        //     if(data.RoomUserInfo.User_ID == $.CommonMainRoom.RoomUserInfo.User_ID){
                        //         onJsToAs({type:"EndLive"}); //结束直播
                        //         alert("您已被请出房间！");
                        //         window.document.location = _VirtualPath.Main;
                        //     }
                        //     return;
                        // }
                        msg = { //设置禁言
                            User1:data.RoomUserInfo_Admin,
                            User2:data.RoomUserInfo,
                        };
                        if(data.Type == 1 || data.Type == 3){
                            msg.Text = (data.Type == 1) ? '{User1} 对 {User2} 设置禁言5分钟。' : '{User1} 对 {User2} 设置 解除禁言。';
                        }else if(data.Type == 2 || data.Type == 4){
                            msg.Text = (data.Type == 2) ? '{User1} 对 {User2} 踢出房间。' : '{User1} 对 {User2} 设置 恢复进房。';
                        }
                        if(msg.User2){
                            _ThisPage.Page.Chat.OutText(msg);
                        }
                    }
                },
                Tip:function (data,settings) {
                    var defaultSetting={
                        title:"提示",
                        msg:"请重试!",
                        timeout:3000,
                        autoclosed:true,
                        type:"xiu-dtip-info"
                    };
                    var settings = arguments[1] ? arguments[1] : defaultSetting;
                    $.extend(defaultSetting,settings);

                    var _Id = new Date().getTime();
                    var _Html = '<div class="xiu-dtip-box" id="'+_Id+'">'+
                                '<div class="xiu-dtip-inner">'+
                                '<div class="xiu-dtip-head">'+
                                '<h2 class="xiu-dtip-title">'+defaultSetting.title+'</h2>'+
                                '<a href="javascript:;" class="xiu-dtip-closed" id="c'+_Id+'"></a>'+
                                '</div>'+
                                '<div class="xiu-dtip-body">'+
                                '<div class="xiu-dtip-content">'+
                                '<p class="dialog-txt">'+data+'</p>'+
                                '</div>'+
                                '</div>'+
                                '</div>'+
                                '</div>';
                    $(".xiu-dtip-box").remove();
                    $("body").append(_Html);
                    $("#c"+_Id).off("click");
                    $("#c"+_Id).on("click",function(){
                        clearTimeout(_Tip);
                        $("#"+_Id).remove();
                    });
                    if(defaultSetting.autoclosed){
                        clearTimeout(_Tip);
                        var _Tip = setTimeout(function () {
                            $("#"+_Id).remove();
                        }, defaultSetting.timeout)
                    }

                },
                //冻结房间按钮
                FrozenRoom:{
                    Data:{
                        Block:false,
                    },
                    Init:function () {
                        if(_StateData.IsAdmin){
                            $("#J_FrozenBtn").show();
                        }else{
                            $("#J_FrozenBtn").hide();
                        }
                        $("#J_FrozenBtn").on("click", function(){
                            if( confirm("是 / 否 冻结【"+$.CommonMainRoom.RoomAnchorInfo.NickName+", 房号："+$.CommonMainRoom.RoomInfo.RoomID+"】房间？") ){
                                $.CommonMainRoom.SocketEmit.BlockSet(true);
                            }
                        });
                    },

                },
                //金币不够，提示充值面板
                PayBoxPanel:{
                    Init:function () {
                        //金币不足，提示充值框，按钮事件
                        $("#J_GiftBuyPanel_payBtn").off("click");
                        $("#J_GiftBuyPanel_payBtn").on("click",function () {
                            $(".GiftBuyPanel").hide();
                        });
                        $("#J_GiftBuyPanel_cancelBtn").off("click");
                        $("#J_GiftBuyPanel_cancelBtn").on("click",function () {
                            $(".GiftBuyPanel").hide();
                        });
                        $("#J_GiftBuyPanel_closeBtn").off("click");
                        $("#J_GiftBuyPanel_closeBtn").on("click",function () {
                            $(".GiftBuyPanel").hide();
                        });

                        //充值按钮 //取消按钮
                        $("#J_GiftBuyTipPanel_EnterBtn, #J_GiftBuyTipPanel_CancelBtn").off("click");
                        $("#J_GiftBuyTipPanel_EnterBtn, #J_GiftBuyTipPanel_CancelBtn").on("click", function(){
                            $("#J_GiftBuyTipPanel").hide();
                        });
                    },
                    Show:function(){
                        $("#J_GiftBuyTipPanel").show();
                    }
                },
            },
            /**
             * 房间相关
             */
            Room:{
                Data:{
                    Attention:false, //是否已关注
                },
                //初始化
                Init:function (data) {
                    _ThisPage.Page.Room.InitAttention(data);
                    _ThisPage.Page.Room.Redpackets();
                },
                //初始化 关注按钮功能
                InitAttention:function (data) {
                    _ThisPage.Page.Room.Data.Attention = data.Attention;
                    //关注按钮
                    updateAttentionBtnText();
                    $("#J_AttentionBtn").off("click");
                    $("#J_AttentionBtn").on("click",function (e) {
                        if (!$.CommonMain.LoginCheck()) return ;
                        if( $.CommonMainRoom.RoomUserInfo.User_ID == $.CommonMainRoom.RoomAnchorInfo.RoomID){
                            Log.Out("艺人不能关注自己");
                            return ;
                        }
                        _ThisPage.Page.Room.Data.Attention = !_ThisPage.Page.Room.Data.Attention;
                        Log.Out("关注 RoomID ", $.CommonMainRoom.RoomAnchorInfo.RoomID);
                        if(_ThisPage.Page.Room.Data.Attention){
                            $.CommonMain.User_Attention($.CommonMainRoom.RoomAnchorInfo.RoomID, null, function (json) {
                                Log.Out("添加关注结果", json);
                            }); //添加关注
                        }else{
                            $.CommonMain.User_Attention($.CommonMainRoom.RoomAnchorInfo.RoomID, _ThisPage.Page.Room.Data.Attention, function (json) {
                                Log.Out("取消关注结果", json);
                            }); //取消关注
                        }
                        (_ThisPage.Page.Room.Data.Attention) ? $.CommonMainRoom.RoomAnchorInfo.Fans++ : $.CommonMainRoom.RoomAnchorInfo.Fans-- ;
                        $("#J_Anchor_Attention").text($.CommonMainRoom.RoomAnchorInfo.Fans);
                        updateAttentionBtnText();
                    });
                    //更新关注按钮 文字
                    function updateAttentionBtnText() {
                        var AttentionText = (_ThisPage.Page.Room.Data.Attention) ? "已关注" : "+关注";
                        var styleText = (_ThisPage.Page.Room.Data.Attention)?' class="AttentionCancel"':"";
                        $("#J_AttentionBtn").html('<a href="javascript:;"'+styleText+'>'+AttentionText+'</a>');
                    }
                },
                //更新房间相关信息
                UpdateInfo:function (data) {
                    // Live:false
                    // Live_CreateDate:null
                    // Live_IsMobile;false/true 是否手机直播
                    // Live_Order_No:null
                    // Live_SocketID:null
                    // Live_SocketID_LinkAnchor:null
                    // Live_SocketID_LinkUser:null
                    // Live_URL:null
                    // Live_URL_LinkAnchor:null
                    // Live_URL_LinkUser:null
                    // Live_UserID_LinkAnchor:null
                    // Live_UserID_LinkUser:null
                    // RoomID:4605
                },
                //游客弹红包
                Redpackets:function () {
                    if($.CommonMainRoom.RoomUserInfo.Guest){
                        var _Html = '<div class="redpackets" id="J_Redpackets">'+
                                    '<div class="packets-content">'+
                                    '<a href="javascript:;" class="packets-closed"></a>'+
                                    '<a href="javascript:;" class="packets-chai"></a>'+
                                    '</div>'+
                                    '</div>';

                        setInterval(function () {
                            if($("body").find("#J_Redpackets").length>0){
                                return;
                            }
                            $("body").append(_Html);

                            $("#J_Redpackets").addClass("zoomInDown animated");
                            $('#J_Redpackets').off('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend');
                            $('#J_Redpackets').on('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
                                $("#J_FlyScreenInputPanel").removeClass("zoomInDown animated");
                            });

                            $(".packets-chai").off("click");
                            $(".packets-chai").on("click",function () {
                                $.CommonMain.LoginCheck();
                            });

                            $("#J_Redpackets").off("click");
                            $("#J_Redpackets").on("click",function(){
                                $.CommonMain.LoginCheck();
                            });

                            $(".packets-closed").off('click');
                            $(".packets-closed").on('click',function(event) {
                                $("#J_Redpackets").remove();
                            });
                        }, 15000);
                    }
                }
            },
            /**
             * 艺人相关
             */
            Anchor:{
                Init:function(){
                    if($.CommonMainRoom.RoomUserInfo.RoomAnchor){
                        $("#J_RoomWelcome").css({width:"220px", float:"left"});
                        $("#J_EditRoomWelcomeBtn").show();
                        $("#J_EditRoomWelcomeBtn").off("click");
                        $("#J_EditRoomWelcomeBtn").on("click", function(){
                            if($("#J_EditRoomWelcomeBtn").text() == "编辑"){
                                $("#J_RoomWelcome").hide();
                                $("#J_RoomWelcomeTxt").show();
                                $("#J_EditRoomWelcomeBtn").text("保存");
                            }
                            else{
                                var dirtyWords = _ThisPage.Page.Chat.MsgFilter($("#J_RoomWelcomeTxt").val());
                                if(dirtyWords.indexOf("*") != -1){
                                    alert("房间信息有敏感词汇！\n请重新编辑。");
                                    return;
                                }
                                if($("#J_RoomWelcomeTxt").val() != $("#J_RoomWelcome").text()){
                                    _ThisPage.Page.Anchor.SaveRoomWelcomeInfo($("#J_RoomWelcomeTxt").val());
                                }
                                $("#J_RoomWelcome").text($("#J_RoomWelcomeTxt").val());
                                $("#J_RoomWelcome").show();
                                $("#J_RoomWelcomeTxt").hide();
                                $("#J_EditRoomWelcomeBtn").text("编辑");
                            }

                        });
                    }else{
                        $("#J_EditRoomWelcomeBtn").hide();
                    }
                    this.InitBadge();
                },
                //保存编辑房间信息
                SaveRoomWelcomeInfo:function(RoomWelcome){
                    $.ajax({
                        url: '/ajax/user.user-anchor.update',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            RoomWelcome: RoomWelcome
                        },
                        success: function (data) {
                            if (data.flag !== 0) {
                                _ThisPage.Page.CommonUitls.Tip(data.msg);
                                return;
                            }
                            // _ThisPage.Page.CommonUitls.Tip("房间信息修改成功");
                        }
                    });
                },
                //更新艺人相关信息
                UpdateInfo:function (data) {
                    $("#J_PicThumb").attr("src", _ThisPage.Page.CommonUitls.GetUserHand(data.RoomID,"80.80"));//艺人头像
                    $("#J_Anchor_NickName").text(data.NickName).attr("title",data.NickName);//艺人昵称
                    $("#J_RoomWelcome").text(data.RoomWelcome); //房间描述数据
                    $("#J_RoomWelcomeTxt").val(data.RoomWelcome); //房间描述数据
                    $("#J_Anchor_Attention").text(data.Fans);//艺人关注人数 【Anchor_Attention这个数据是艺人关注了多少人】
                    $("#J_AnchorPomeloNum").text(data.Pomelo);//艺人的星星
                    $("#J_Anchor_EXP").text(data.EXP);//艺人经验
                    $("#J_Anchor_EXP_Difference").text(data.EXP_Difference);//艺人差多少经验升级
                    var prcent = ( (data.EXP / data.EXP_Next).toFixed(2) * 100 ) + "%";//升级差距进度条
                    $("#J_Exp_Prcent").css('width', prcent);
                    data.Level = (data.Level == 0) ? 1 : data.Level; //艺人等级 从1开始
                    var Src = _VirtualPath.Static + "main/image/common/level/anchor/" + data.Level + ".png";
                    $("#J_Anchor_Level").attr("src", Src);
                },
                //初始化 艺人徽章
                InitBadge:function(){

                    var anchorHZ = $.CommonMainRoom.RoomAnchorInfo.EmblemList;
                    var hz = _PageData.Commodity.Emblem.Data;
                    // if(anchorHZ == null) return;
                    if(hz == null) return;

                    $("#J_Badge").empty();
                    for(var i=0;i<hz.length;i++){
                        var hzObj = hz[i];
                        if(hzObj.Type == 1 && !hzObj.Status){
                            var status = GetAnchorIndex(anchorHZ, hzObj.ID);
                            var imgTitle = (status=='0') ? hzObj.Name : "上周周星"+hzObj.Name;
                            var img = '<img src="'+_VirtualPath.Static+'main/image/room/icon/badge/'+hzObj.ID+'_'+status+'.png" alt="'+imgTitle+'" title="'+imgTitle+'">';
                            $("#J_Badge").append(img);
                        }
                    }

                    function GetAnchorIndex(anchorHZ, hzID){
                        if(!anchorHZ) return"0";
                        for(var i=0;i<anchorHZ.length;i++){
                            if(anchorHZ[i].Item_ID == hzID){
                                return "1";
                            }
                        }
                        return "0";
                    }
                }
            },
            /**
             * 自己相关的
             */
            Self:{
                Data:{

                },
                //个人名片 自己的 用户信息
                Init:function (data) {
                    $("#J_MiniUserHead").off('click');
                    $("#J_MiniUserHead").on('click',function(event) {
                        if($("#J_MiniUserBase").is(":visible")){
                            $("#J_MiniUserBase").fadeOut(300);//隐藏
                        }else{
                            $("#J_MiniUserBase").fadeIn(300);//显示
                            $.CommonMain.User_UserInfo(function (json) {
                                $("#J_MUser_Diff").text(json.data.EXP_Difference);
                                $("#J_SelfCoin").text(json.data.Coin);
                            });
                        }
                    });

                    $("#J_MiniUserBase").off('mouseleave');
                    $("#J_MiniUserBase").on("mouseleave",function () {
                        $(this).hide();
                    });

                    //修改昵称按钮事件
                    $("#J_EditNickNameImgBtn").on("click", function () {
                        $("#J_MNickNameInputText").val($.CommonMainRoom.RoomUserInfo.NickName);
                        $("#J_MNickNameUI2").show();
                        $("#J_MNickNameUI1,#J_MAnchor_Level,#J_MUser_Level").hide();

                    });
                    $("#J_MNickNameSaveBtn").on("click", function () {
                        var NickName = filterXSS($("#J_MNickNameInputText").val());
                        if(NickName.length <= 0 || $.CommonMainRoom.RoomUserInfo.NickName == NickName){
                            $("#J_MNickNameUI2").hide();
                            $("#J_MNickNameUI1,#J_MAnchor_Level,#J_MUser_Level").show();
                            return ;
                        }

                        var dirtyWords = _ThisPage.Page.Chat.MsgFilter(NickName);

                        if(dirtyWords.indexOf("*") != -1){
                            alert("昵称带有敏感词语！");
                            return;
                        }

                        //去调用ajax修改后，刷新页面
                        $.ajax({
                            url: '/ajax/user.user-info.update',
                            type: 'post',
                            dataType: 'json',
                            data: {
                                NickName: NickName
                            },
                            success: function (data) {
                                $("#J_MNickNameUI2").hide();
                                $("#J_MNickNameUI1,#J_MAnchor_Level,#J_MUser_Level").show();
                                $("#J_MNickname").text(NickName);
                                if (data.flag !== 0) {
                                    _ThisPage.Page.CommonUitls.Tip(data.msg);
                                    return;
                                }
                                _ThisPage.Page.CommonUitls.Tip("昵称修改成功");
                                setTimeout(function () {
                                    var host = window.location.host;
                                    var href = window.location.href;
                                    href = href.replace("http://" + host, "");
                                    location.href = href;
                                }, 2000);
                            }
                        });

                    });

                    $("#J_SelfInfoBadge").html(_ThisPage.Page.Chat.CommonUtils.GetBadgeIconHtml($.CommonMainRoom.RoomUserInfo.EmblemList));
                },
                UpdateInfo:function (data) {
                    // if(data.RoomAnchor){
                        // $("#J_MAnchor_Level").attr('alt', _ThisPage.RoomData.Anchor_Level);
                        // $("#J_MAnchor_Level").attr('src',_VirtualPath.Static+"main/image/common/level/anchor/"+_ThisPage.RoomData.Anchor_Level+".png");
                    // }else{
                    //     $("#J_MAnchor_Level").remove();
                    // }
                    $("#J_MUser_Level").attr('alt', data.Level);
                    $("#J_MUser_Level").attr('src',_VirtualPath.Static+"main/image/common/level/user/"+data.Level+".png");
                    var prcent = (data.EXP / data.EXP_Next).toFixed(2) * 100 + "%";
                    $("#J_MUser_Exp").css('width', prcent);

                    $("#J_SelfHeadImg").attr("src", _ThisPage.Page.CommonUitls.GetUserHand(data.User_ID));
                    $("#J_MUser_Diff").text(data.EXP_Difference);
                    $("#J_MiniUserHeadImg").attr("src", _ThisPage.Page.CommonUitls.GetUserHand(data.User_ID));
                    $("#J_MNickname").text(data.NickName);

                    //需要 更新人员列表
                    if ($("#J_UserList li[data-uid=" + data.User_ID + "] .J_UserLevelIcon").find("img").length > 0) {
                        var level = data.RoomAnchor ? $.CommonMainRoom.RoomAnchorInfo.Level : data.Level;
                        var path = data.RoomAnchor ? "anchor/" : "user/";
                        path =  _VirtualPath.Static+'main/image/common/level/'+path+level+'.png';
                        $("#J_UserList li[data-uid=" + data.User_ID + "] .J_UserLevelIcon img").attr("src",path);
                    }
                }
            },
            /**
             * 视频相关
             */
            Video:{
                Data:{
                    IsChangeCdn: false
                },
                CommonUtils:{
                    //开始直播事件
                    LiveStartEvent:function(){
                        $.CommonMainRoom.SocketEmit.Live();
                    },
                    //结束直播事件
                    LiveEndEvent:function(){
                        $.CommonMainRoom.SocketEmit.LiveEnd();
                    }
                },
                //初始化
                Init:function () {
                    _ThisPage.Page.Video.GetRecommend(!$.CommonMainRoom.RoomInfo.Live);
                    _ThisPage.Page.Video.ActivityLink($.CommonMainRoom.RoomInfo.Live);
                    _ThisPage.Flash.JoinRoom($.CommonMainRoom.RoomInfo);
                    if($.CommonMainRoom.RoomUserInfo.RoomAnchor){
                        if($.CommonMainRoom.RoomInfo.Live){
                            _ThisPage.Page.Video.ShowLiveBtn(false);
                            $("#J_LiveStarSwpBtn").hide();
                            $("#J_LiveEndBtn").show();
                        }else{
                            _ThisPage.Page.Video.ShowLiveBtn(true);
                            $("#J_LiveStarSwpBtn").show();
                            $("#J_LiveEndBtn").hide();
                            //第二次进入房间 艺人页 显示结束直播界面
                            _ThisPage.Page.Video.LiveEnd();
                        }
                    }
                    //开始直播/结束直播
                    $("#J_LiveStartBtn").off("click");
                    $("#J_LiveStartBtn").on("click", function(){
                        Log.Out("开始直播");
                        $("#J_LiveStarSwpBtn").hide();
                        $("#J_LiveEndBtn").hide();
                        onJsToAs( { type:"SelectCamear" } );
                    });
                    $("#J_LiveEndBtn").off("click");
                    $("#J_LiveEndBtn").on("click", function(){
                        Log.Out("结束直播");
                        $("#J_LiveStarSwpBtn").hide();
                        $("#J_LiveEndBtn").hide();
                        $.CommonMainRoom.SocketEmit.LiveEnd();
                    });
                    //切换大屏小屏
                    $("#J_LiveSwpBtn").off("click");
                    $("#J_LiveSwpBtn").on("click", function(){

                        // Log.Out("开始直播");
                        // $("#J_LiveStarSwpBtn").hide();
                        // $("#J_LiveEndBtn").hide();
                        // onJsToAs( { type:"SelectCamear" } );
                        // return;

                        Log.Out("切换大屏");
                        $.ajax({
                            url: '/ajax/user.user-anchor.update',
                            type: 'post',
                            dataType: 'json',
                            data: {
                                RoomTemplate: "iMax", //RoomTemplate ("Classic", "iMax")
                                Live_IsMobile: 0 //是否 手机直播
                            },
                            success: function (data) {
                                Log.Out("切换大屏",data);
                                if (data.flag !== 0) {
                                    _ThisPage.Page.CommonUitls.Tip("Error "+data.msg+" "+data.flag);
                                    return;
                                }
                                _ThisPage.Page.CommonUitls.Tip("切换【大屏直播间】成功！");
                                setTimeout(function(){
                                    window.location.reload();
                                }, 2000);
                            }
                        });
                    });
                },
                //获取 推荐位
                GetRecommend:function (isShow) {
                    if( $.CommonMainRoom.RoomUserInfo.RoomAnchor )return ;
                    if(!isShow){
                        //清空 隐藏
                        $("#J_RecommendAnchor").hide();
                        return ;
                    }else{
                        $("#J_RecommendAnchor").show();
                    }
                    $.ajax({
                        url: '/ajax/user.user-anchor.page',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            Cache: true,
                            iDisplayStart: 0,
                            iDisplayLength: 3,
                            //                F_Tags: "有沟",
                            //                F_Status: "1",
                            //                Sort_Col: "New"
                        },
                        success: function (data) {
                            if (data.flag !== 0) {
                                _ThisPage.Page.CommonUitls.Tip("Error "+data.msg+" "+data.flag);
                                return;
                            }
                            // _ThisPage.PageParm.Total = data.iTotalRecords;
                            // _ThisPage.PageParm.MaxCode = data.sMaxCode;
                            // _ThisPage.PageParm.Start += _ThisPage.PageParm.Length;
                            // Log.Out(data.aaData);
                            _ThisPage.Page.Video.AddRecommend(data.aaData);
                        }
                    });
                },
                //添加推荐艺人
                AddRecommend:function (allData) {
                    var s = "";
                    for(var i=0;i<allData.length;i++){
                        var itemHtml = '<li class="listitem">' +
                            '<p>' +
                            '<a href="/room/'+allData[i].User_ID+'">' +
                            '<img src="'+_ThisPage.Page.CommonUitls.GetAvatarHand(allData[i].User_ID,"160.126")+'" alt="'+allData[i].NickName+'" class="_thumb">' +
                            '</a>' +
                            '</p>' +
                            '<p>' +
                            '<i class="ico-lev"><img src="'+_VirtualPath.Static+'main/image/common/level/anchor/'+allData[i].Anchor_Level+'.png" alt=""></i><a href="/room/13">'+allData[i].NickName+'</a>' +
                            '</p>' +

                            '</li>';
                        s += itemHtml;
                    }
                    $("#J_RecommendAnchorList").html(s);
                },
                //是否显示 开始直播/结束直播
                ShowLiveBtn:function (isShow) {
                    if(isShow){
                        Log.Out("显示开播按钮");
                        $("#J_LiveBtnDiv").show();
                    }else{
                        Log.Out("隐藏开播按钮");
                        $("#J_LiveBtnDiv").hide();
                    }
                },
                //收到艺人结束直播动作
                LiveEnd:function(){
                    _ThisPage.Flash.EndLive();
                    if($.CommonMainRoom.RoomUserInfo.RoomAnchor){
                        $("#J_LiveStarSwpBtn").show();
                        $("#J_LiveEndBtn").hide();
                    }else{
                        _ThisPage.Page.Video.GetRecommend(true);
                    }
                    _ThisPage.Page.Video.ActivityLink(false);

                    //如果是切换CDN的话，就自动开播。
                    if(_ThisPage.Page.Video.Data.IsChangeCdn){
                        _ThisPage.Page.Video.Data.IsChangeCdn = false;
                        $.CommonMainRoom.SocketEmit.Live();
                    }
                },
                //活动 ICON
                ActivityLink:function(isShow){
                    if(isShow){
                        $("#J_ActivityLink").show();
                    }else{
                        $("#J_ActivityLink").hide();
                    }
                }
            },
            /**
             * 聊天
             */
            Chat:{
                Data:{
                    Word:[],//脏话 过滤词
                    Intreval:0,//发言时间间隔
                    Maxlength:0,//发送文字最长限制
                    isCanSend:true,//是否 可以发送文字
                    isMouseAreaFaceEmo:false,//鼠标是否在 表情区域
                    MsgMaxCount:500,//最大条数
                    TestInterval:0,//测试Interval
                    TestMaxCount:0,//测试消息条数
                    TestCurrCount:0,//测试数据当前条数

                    MsgArr:[],//当前消息 xxx
                    MsgObj:null,//当前消息

                    ChatUser:{ //公聊 私聊 切换数据
                        Receiver:null,
                        Private:false,
                        PrivateTa:false
                    },
                    Config:[
                        //等级    发言间隔    聊天字数    是否允许私聊
                        {level:0,interval:5,char:10,private:0},
                        {level:1,interval:3,char:30,private:0},
                        {level:2,interval:3,char:30,private:0},
                        {level:3,interval:3,char:30,private:1},
                        {level:4,interval:3,char:30,private:1},
                        {level:5,interval:3,char:30,private:1},
                        {level:6,interval:3,char:30,private:1},
                        {level:7,interval:3,char:30,private:1},
                        {level:8,interval:3,char:30,private:1},
                        {level:9,interval:3,char:30,private:1},
                        {level:10,interval:2,char:30,private:1},
                        {level:11,interval:2,char:30,private:1},
                        {level:12,interval:2,char:30,private:1},
                        {level:13,interval:2,char:30,private:1},
                        {level:14,interval:2,char:30,private:1},
                        {level:15,interval:2,char:30,private:1},
                        {level:16,interval:2,char:30,private:1},
                        {level:17,interval:2,char:30,private:1},
                        {level:18,interval:2,char:30,private:1},
                        {level:19,interval:1,char:30,private:1},
                        {level:20,interval:1,char:30,private:1},
                        {level:21,interval:1,char:30,private:1},
                        {level:22,interval:1,char:30,private:1},
                        {level:23,interval:1,char:30,private:1},
                        {level:24,interval:1,char:30,private:1},
                        {level:25,interval:1,char:30,private:1},
                        {level:26,interval:1,char:30,private:1},
                        {level:27,interval:1,char:30,private:1},
                        {level:28,interval:1,char:30,private:1},
                        {level:29,interval:1,char:30,private:1},
                        {level:30,interval:1,char:30,private:1},
                        {level:31,interval:1,char:30,private:1},
                        {level:32,interval:1,char:30,private:1},
                        {level:33,interval:1,char:30,private:1},
                        {level:34,interval:1,char:30,private:1},
                        {level:35,interval:1,char:30,private:1},
                        {level:36,interval:1,char:30,private:1}
                    ]
                },
                //测试自动发布消息
                TestAutoSendMsg:function () {
                    if(_ThisPage.Page.Chat.Data.TestCurrCount >= _ThisPage.Page.Chat.Data.TestMaxCount){
                        clearInterval(_ThisPage.Page.Chat.Data.TestInterval);
                        $("#J_InputTextWord").val("game over");
                        _ThisPage.Page.Chat.Data.TestCurrCount = 0;
                        _ThisPage.Page.Chat.Data.TestMaxCount = 0;
                        return;
                    }
                    _ThisPage.Page.Chat.Data.TestCurrCount++;
                    $("#J_InputTextWord").val("Test Text " + _ThisPage.Page.Chat.Data.TestCurrCount );
                    var txt = $("#J_InputTextWord").val();
                    var msgObj = {};
                    msgObj.Private = false;
                    msgObj.PrivateTa = false;
                    msgObj.text = txt;
                    msgObj.User1 = _ThisPage.Page.Chat.GetMsgUserFormat($.CommonMainRoom.RoomUserInfo);
                    msgObj.User2 = null;
                    _ThisPage.Page.Chat.Data.MsgObj = msgObj;
                    // _ThisPage.Page.Chat.ChatShowMsg(msgObj);
                    $.CommonMainRoom.SocketEmit.Message(msgObj.text);
                },
                //公共方法
                CommonUtils:{
                    getUserName:function(UserData, isPrivate){
                        // Log.Out("公共方法getUserName", UserData);
                        var levelImgPath = (UserData.RoomAnchor) ? "anchor/" : "user/";
                        var anchorLevel = $.CommonMainRoom.RoomAnchorInfo.Level;
                        var userLevel = UserData.Level;
                        var level = (UserData.RoomAnchor) ? anchorLevel : userLevel;
                        var msg = "";
                        // if (UserData.RoomAnchor) msg += '<em class="userlev"><img src="' + _VirtualPath.Static + 'main/image/common/level/anchor/'+anchorLevel +'.png" alt="' + anchorLevel + '"></em>';
                        // msg += '<em class="userlev"><img src="' + _VirtualPath.Static + 'main/image/common/level/user/'+userLevel +'.png" alt="' + userLevel + '"></em>';
                        if (UserData.IsMobile) msg += '<em class="isVip"><img src="' + _VirtualPath.Static + 'main/image/room/icon/mobile.png" alt="手机"></em>';
                        if (!UserData.Guest) msg += '<em class="userlev"><img src="' + _VirtualPath.Static + 'main/image/common/level/'+levelImgPath+level +'.png" alt="' + level + '"></em>';
                        if (UserData.VIP > 0) msg += '<em class="isVip"><img src="' + _VirtualPath.Static + 'main/image/room/icon/vip.png" alt="' + UserData.VIP + '"></em>';
                        if (UserData.RoomAdmin) msg += '<em class="isAdmin"><img src="' + _VirtualPath.Static + 'main/image/room/icon/Ico-admin.png" alt="管理"></em>';
                        if (UserData.IsAdmin) msg += '<em class="isAdmin"><img src="' + _VirtualPath.Static + 'main/image/room/icon/Ico-official.png" alt="官方"></em>';
                        if (UserData.RoomGuardian && UserData.RoomGuardianMode == "MONTH") msg += '<em class="isGguard"><img src="' + _VirtualPath.Static + 'main/image/room/icon/Ico-guard-month.png" alt="月守护"></em>';
                        if (UserData.RoomGuardian && UserData.RoomGuardianMode == "YEAR") msg += '<em class="isGguard"><img src="' + _VirtualPath.Static + 'main/image/room/icon/Ico-guard-year.png" alt="年守护"></em>';
                        if (UserData.EmblemList) msg += _ThisPage.Page.Chat.CommonUtils.GetBadgeIconHtml(UserData.EmblemList);
                        var NickName = (isPrivate && UserData.User_ID == $.CommonMainRoom.RoomUserInfo.User_ID) ? "我" : UserData.NickName;
                        msg += '<span class="username" data-uid=' + UserData.User_ID + '>'+NickName+'</span>';

                        return msg;
                    },
                    //获取徽章
                    GetBadgeIconHtml:function (EmblemList) {
                        if(EmblemList==null) return;
                        if(typeof EmblemList == "String") return;
                        var s = "";
                        for(var i=0; i<EmblemList.length; i++){
                            if(EmblemList[i].Item_Type == 2){
                                s += '<em class="isVip"><img src="' + _VirtualPath.Static + 'main/image/room/icon/badge/'+EmblemList[i].Item_ID+'_1.png" alt="'+EmblemList[i].Item_Name+'" title="'+EmblemList[i].Item_Name+'"></em>';
                            }
                        }
                        return s;
                    }
                },
                //初始化
                Init:function (data) {
                    _ThisPage.Page.Chat.Data.isCanSend = true;
                    //游客弹出登录框
                    $("#J_InputTextWord").focusin(function (e) {
                        $.CommonMain.LoginCheck();
                    });

                    //发送按钮 输入框 回车
                    $("#J_TalkPublishBtn").off('click');
                    $("#J_TalkPublishBtn").on('click', function (e) {
                        _ThisPage.Page.Chat.ChatSendEvent();
                    });
                    $("#J_InputTextWord").off('keyup');
                    $("#J_InputTextWord").on('keyup', function (e) {
                        if (e.keyCode == 13) {
                            _ThisPage.Page.Chat.ChatSendEvent();
                        }
                    });

                    //处理聊天切换面板
                    $("#J_ChatTab").off('click');
                    $("#J_ChatTab").on('click', 'a', function (event) {
                        var index = $(this).index();
                        _ThisPage.Page.Chat.ChatSelectTab(index);
                    });

                    //处理聊天表情
                    $("#J_TalkFaceBtn").off('click');
                    $("#J_TalkFaceBtn").on('click',function(event) {
                        event.preventDefault();
                        if ($('#J_FaceEmoLayer').is(':hidden')) {
                            $('#J_FaceEmoLayer').show();
                            setTimeout(function () {
                                $(window).off("click");
                                $(window).on("click",function (e) {
                                    if(_ThisPage.Page.Chat.Data.isMouseAreaFaceEmo) return;
                                    _ThisPage.Page.Chat.ChatCloseFaceEmoPanel();
                                });
                            }, 10);
                        } else {
                            _ThisPage.Page.Chat.ChatCloseFaceEmoPanel();
                        }
                    });
                    $('#J_FaceEmoLayer').on("mouseover",function () {
                        _ThisPage.Page.Chat.Data.isMouseAreaFaceEmo = true;
                    });
                    $('#J_FaceEmoLayer').on("mouseout",function () {
                        _ThisPage.Page.Chat.Data.isMouseAreaFaceEmo = false;
                    });

                    $('.FaceTab').off('click');
                    $('.FaceTab').on('click', 'li', function(event) {
                        var index = $(this).index();
                        $(this).addClass('active').siblings().removeClass('active')
                        $('#J_FaceEmoCont .SingleEmo').eq(index).show().addClass('SingleEmoActive').siblings().hide().removeClass('SingleEmoActive');
                    });


                    //艺人 官方 不限制字数
                    if( !($.CommonMainRoom.RoomUserInfo.RoomAnchor || $.CommonMainRoom.RoomUserInfo.IsAdmin) ){
                        _ThisPage.Page.Chat.Data.Maxlength = _ThisPage.Page.Chat.Data.Config[$.CommonMainRoom.RoomUserInfo.Level].char;
                        $("#J_InputTextWord").attr("maxlength", _ThisPage.Page.Chat.Data.Maxlength);
                    }

                    //选择表情
                    $(".EmoList").off('click');
                    $(".EmoList").on('click', 'li', function(event) {
                        var _val = $(this).find('img').attr('alt');
                        var tempS = $("#J_InputTextWord").val()+"["+_val+"]";
                        if( !($.CommonMainRoom.RoomUserInfo.RoomAnchor || $.CommonMainRoom.RoomUserInfo.IsAdmin) && tempS.length > _ThisPage.Page.Chat.Data.Maxlength ){
                            _ThisPage.Page.Chat.ChatCloseFaceEmoPanel();
                            return;
                        }
                        $("#J_InputTextWord").val($("#J_InputTextWord").val()+"["+_val+"]");
                        $("#J_InputTextWord").focus();
                        _ThisPage.Page.Chat.ChatCloseFaceEmoPanel();
                    });

                    _ThisPage.Page.Chat.FaceEmo.InitPanel();//初始化表情面板，VIP，守护，是否显示开通按钮等。
                    _ThisPage.Page.Chat.InitScrollBar();
                    _ThisPage.Page.Chat.InitLoadWord(_VirtualPath.Static+"/main/js/room.chat.word.txt");

                    //提示进入房间
                    _ThisPage.Page.Chat.RoomEnterNewUserNotify(data);
                    //系统提示
                    _ThisPage.Page.Chat.SysText("<span class='ChatSysTips'><a href='"+_VirtualPath.Main+"activity/2016/firstpay' target='_blank'>系统消息：首次充值赠送幸运大礼包！</a></span>");
                    //游客诱导文字
                    _ThisPage.Page.Chat.GuestText.Init();
                },
                //初始化 聊天区 滚动条
                InitScrollBar: function () {
                    $("#J_WebChatList").perfectScrollbar();
                    $("#J_WebChatListPrivate").perfectScrollbar();
                    $("#J_GameList").perfectScrollbar();
                    $("#J_EmoJi_Box").perfectScrollbar();
                },
                //加载敏感词
                InitLoadWord:function (url) {
                    if( _ThisPage.Page.Chat.Data.Word.length > 0 ) return ;
                    $.get(url,{},function(data) {
                            _ThisPage.Page.Chat.Data.Word = data.split("|");
                        },
                        "text"
                    );
                },
                //发送消息事件
                ChatSendEvent: function () {
                    if (!$.CommonMain.LoginCheck()) {
                        return;
                    }

                    var txt = $("#J_InputTextWord").val().trim();
                    if (!txt) return ;

                    //测试消息
                    var re = /\[test:([0-9]*)\]/g;
                    if(re.test(txt)){
                        _ThisPage.Page.Chat.Data.TestCurrCount = 0;
                        _ThisPage.Page.Chat.Data.TestMaxCount = Number( txt.replace(/\[test:([0-9]*)\]/g,'$1') );
                        clearInterval(_ThisPage.Page.Chat.Data.TestInterval);
                        _ThisPage.Page.Chat.Data.TestInterval = setInterval(_ThisPage.Page.Chat.TestAutoSendMsg, 70);
                        return ;
                    }

                    var msgObj = {};
                    msgObj.Private = (_ThisPage.Page.Chat.Data.ChatUser.Receiver) ? _ThisPage.Page.Chat.Data.ChatUser.Private : false;
                    msgObj.PrivateTa = (_ThisPage.Page.Chat.Data.ChatUser.Receiver) ? _ThisPage.Page.Chat.Data.ChatUser.PrivateTa : false;
                    Log.Out("发送消息", msgObj);

                    //房间艺人 官方 没加 发言间隔
                    if( !($.CommonMainRoom.RoomUserInfo.RoomAnchor || $.CommonMainRoom.RoomUserInfo.IsAdmin) ){

                        //发言时间间隔
                        if(!_ThisPage.Page.Chat.Data.isCanSend) return ;
                        var config = _ThisPage.Page.Chat.Data.Config[$.CommonMainRoom.RoomUserInfo.Level];
                        if( msgObj.Private && !config.private ){
                            _ThisPage.Page.CommonUitls.Tip("您升级到【3富】即可开启私聊功能！");
                            return ;
                        }

                        _ThisPage.Page.Chat.Data.isCanSend = false;
                        clearInterval(_ThisPage.Page.Chat.Data.Interval);
                        var time = config.interval;
                        $("#J_TalkPublishBtn").text(time+"秒");
                        _ThisPage.Page.Chat.Data.Interval = setInterval(function () {
                            time--;
                            $("#J_TalkPublishBtn").text(time+"秒");
                            if(time <= 0){
                                _ThisPage.Page.Chat.Data.isCanSend = true;
                                clearInterval(_ThisPage.Page.Chat.Data.Interval);
                                $("#J_TalkPublishBtn").text("发送");
                                $("#J_TalkPublishBtn").css({opacity:1});
                            }
                        },1000);
                        //发言长度限制
                        _ThisPage.Page.Chat.Data.Maxlength = config.char;
                        $("#J_InputTextWord").attr("maxlength", _ThisPage.Page.Chat.Data.Maxlength);
                        $("#J_TalkPublishBtn").css({opacity:0.5});
                    }

                    //脏话过滤
                    txt = _ThisPage.Page.Chat.MsgFilter(txt);

                    msgObj.text = txt;
                    msgObj.User1 = _ThisPage.Page.Chat.GetMsgUserFormat($.CommonMainRoom.RoomUserInfo);
                    msgObj.User2 = (_ThisPage.Page.Chat.Data.ChatUser.Receiver) ? _ThisPage.Page.Chat.GetMsgUserFormat(_ThisPage.Page.Chat.Data.ChatUser.Receiver) : null;

                    _ThisPage.Page.Chat.Data.MsgObj = msgObj;
                    // _ThisPage.Page.Chat.ChatShowMsg(msgObj);


                    if(msgObj.Private){
                        $.CommonMainRoom.SocketEmit.Message(txt, msgObj.User2.User_ID, true);
                        Log.Out("私聊", msgObj.User2.User_ID);
                    }else if(msgObj.PrivateTa){
                        $.CommonMainRoom.SocketEmit.Message(txt, msgObj.User2.User_ID);
                        Log.Out("对他说", msgObj.User2.User_ID);
                    }else{
                        $.CommonMainRoom.SocketEmit.Message(txt);
                        Log.Out("公聊");
                    }
                    //发送完成之后清空输入框
                    $("#J_InputTextWord").val('').focus();
                },
                //获取 聊天 用户数据格式
                GetMsgUserFormat:function (UserData) {
                    var data = {};
                    data.isGuest = UserData.Guest;
                    data.IsAdmin = UserData.IsAdmin;
                    data.IsAnchor = UserData.IsAnchor;
                    data.IsFamily = UserData.IsFamily;
                    data.IsMobile = UserData.IsMobile;
                    data.User_ID = UserData.User_ID;
                    data.Level = UserData.Level;
                    data.AnchorLevel = (data.User_ID == $.CommonMainRoom.RoomAnchorInfo.RoomID) ? $.CommonMainRoom.RoomAnchorInfo.Level : -1;
                    data.NickName = UserData.NickName;
                    data.RoomAdmin = UserData.RoomAdmin;
                    data.RoomAnchor = UserData.RoomAnchor;
                    data.RoomGuardian = UserData.RoomGuardian;
                    data.RoomGuardianMode = UserData.RoomGuardian_Mode;
                    data.VIP = UserData.VIP;
                    return data;
                },
                //接收消息处理
                ChatServerMsgReceive: function (data) {
                    data.Receiver = data.RoomUserInfo_Receiver;//兼容
                    var msgObj = {};
                    if(data.Private){
                        msgObj.Private = (data.Private) ? data.Private : false;
                        msgObj.PrivateTa = (data.Sender) ? true : false;
                        msgObj.text = data.Message;
                        msgObj.User1 = _ThisPage.Page.Chat.GetMsgUserFormat(data.RoomUserInfo);
                        msgObj.User2 = _ThisPage.Page.Chat.GetMsgUserFormat($.CommonMainRoom.RoomUserInfo);
                        $("#J_ChatNewMsgTip").addClass('NewMsgRec').show();
                    }else{
                        msgObj.Private = (data.Private) ? data.Private : false;
                        msgObj.PrivateTa = (data.Receiver) ? true : false;
                        msgObj.text = data.Message;
                        msgObj.User1 = _ThisPage.Page.Chat.GetMsgUserFormat(data.RoomUserInfo);
                        msgObj.User2 = (data.Receiver) ? _ThisPage.Page.Chat.GetMsgUserFormat(data.Receiver) : null;
                    }
                    _ThisPage.Page.Chat.ChatShowMsg(msgObj);
                },
                //显示聊天消息
                ChatShowMsg:function (msgObj) {
                    Log.Out("msgObj", msgObj);
                    var msg = "";
                    if(msgObj.Private){
                        msg = "<li>"+_ThisPage.Page.Chat.CommonUtils.getUserName(msgObj.User1, true) + " <span>悄悄对</span> " + _ThisPage.Page.Chat.CommonUtils.getUserName(msgObj.User2, true) + " <span>说</span>：" + getUserMsgText(msgObj.User1, msgObj.text)+"</li>";
                        $("#J_ChatlistinfoPrivate").append(msg);
                        $("#J_ChatlistinfoPrivate span[data-uid=" + msgObj.User1.User_ID + "]").data('userdata', msgObj.User1);
                        $("#J_ChatlistinfoPrivate span[data-uid=" + msgObj.User2.User_ID + "]").data('userdata', msgObj.User2);
                    }else if(msgObj.PrivateTa){
                        msg = "<li>"+_ThisPage.Page.Chat.CommonUtils.getUserName(msgObj.User1, false) + " <span>对</span> " + _ThisPage.Page.Chat.CommonUtils.getUserName(msgObj.User2, false) + " <span>说</span>：" + getUserMsgText(msgObj.User1, msgObj.text)+"</li>";
                        $("#J_Chatlistinfo").append(msg);
                        $("#J_Chatlistinfo span[data-uid=" + msgObj.User1.User_ID + "]").data('userdata', msgObj.User1);
                        $("#J_Chatlistinfo span[data-uid=" + msgObj.User2.User_ID + "]").data('userdata', msgObj.User2);
                    }else{
                        msg = "<li>"+_ThisPage.Page.Chat.CommonUtils.getUserName(msgObj.User1, false) + " <span>说</span>：" + getUserMsgText(msgObj.User1, msgObj.text)+"</li>";
                        $("#J_Chatlistinfo").append(msg);
                        $("#J_Chatlistinfo span[data-uid=" + msgObj.User1.User_ID + "]").data('userdata', msgObj.User1);
                    }
                    _ThisPage.Page.Chat.ChatScrollToBottom();
                    //回收html节省
                    if($("#J_Chatlistinfo").children().length > _ThisPage.Page.Chat.Data.MsgMaxCount){
                        $("#J_Chatlistinfo").children()[0].remove();
                    }
                    //根据 vip 守护 对文字进行 加颜色 表情转义图片
                    function getUserMsgText(UserData, MessageText) {
                        var msg = "";
                        if (UserData.VIP > 0) {
                            msg += '<span class="vipcolor">' + _ThisPage.Page.Chat.FaceEmo.FaceEscape(UserData, MessageText) + '</span>';
                        } else if (UserData.RoomGuardian) {
                            msg += '<span class="shcolor">' + _ThisPage.Page.Chat.FaceEmo.FaceEscape(UserData, MessageText) + '</span>';
                        }else {
                            msg += '<span>' + _ThisPage.Page.Chat.FaceEmo.FaceEscape(UserData, MessageText) + '</span>';
                        }
                        return msg;
                    }
                },
                //进房提示语
                RoomEnterNewUserNotify:function (data) {
                    if(data.MountsInfo != null){
                        if(_ThisPage.Page.Gift.Data.isEffectOn){
                            //显示 座驾效果
                            data.UserInfo = data.RoomUserInfo;
                            //年守护 修改显示动画时间
                            if(data.MountsInfo.id == "Guardian-YEAR"){
                                data.MountsInfo.EffectDuration = 6000;
                            }
                            GiftEffectFactory.ShowMount(data, "mount");
                        }
                    }
                    var MountsInfo = data.MountsInfo;
                    var AnchorInfo = $.CommonMainRoom.RoomAnchorInfo;
                    var UserInfo = data.RoomUserInfo;

                    var _Path = UserInfo.RoomAnchor ? "anchor/" : "user/";
                    var _Level = UserInfo.RoomAnchor ? AnchorInfo.Level : UserInfo.Level;

                    var msg = '';
                    msg += '<li class="enter">';
                    msg += '<span class="welcome">欢迎</span>';
                    // if(!UserInfo.Guest){ //游客无图标
                    //     msg += '<em class="userlev"><img src="' + _VirtualPath.Static + 'main/image/common/level/' + _Path + _Level + '.png" alt="' + _Level + '"></em>';
                    // }
                    // if (UserInfo.VIP > 0) {
                    //     msg += '<em class="isVip"><img src="' + _VirtualPath.Static + 'main/image/room/icon/vip.png" alt="' + UserInfo.VIP + '"></em>';
                    // }
                    // if (UserInfo.RoomAdmin) {
                    //     msg += '<em class="isAdmin"><img src="' + _VirtualPath.Static + 'main/image/room/icon/Ico-admin.png" alt="管理"></em>';
                    // }

                    var welcomeText = "进入房间 ";
                    if(UserInfo.RoomGuardian){ //是否 守护
                        // if (UserInfo.RoomGuardian_Mode == "MONTH") { //月守护
                        //     msg += '<em class="isGuard"><img src="' + _VirtualPath.Static + 'main/image/room/icon/Ico-guard-month.png" alt="月守护"></em>';
                        // }else if (UserInfo.RoomGuardian_Mode == "YEAR") { //年守护
                        //     msg += '<em class="isGuard"><img src="' + _VirtualPath.Static + 'main/image/room/icon/Ico-guard-year.png" alt="年守护"></em>';
                        // }
                        welcomeText = '坐着</span> <b>'+MountsInfo.Name+'</b> <span>出来！';
                    }
                    if(MountsInfo != null){ //如果有座驾 可能是等级座驾 可能是购买的座驾
                        welcomeText = '坐着 </span> <b>'+MountsInfo.Name+'</b> <span>出来！';
                    }
                    // if (UserInfo.IsAdmin) {
                    //     msg += '<em class="isAdmin"><img src="' + _VirtualPath.Static + 'main/image/room/icon/Ico-official.png" alt="官方"></em>';
                    // }
                    msg += this.CommonUtils.getUserName(UserInfo,false);
                    // msg += '<span class="username" data-uid=' + UserInfo.User_ID + '>' + UserInfo.NickName + '</span>';
                    msg += '<span>'+welcomeText+'</span>';
                    msg += '</li>';
                    $("#J_Chatlistinfo").append(msg);
                    if (!UserInfo.Guest) {
                        $("#J_Chatlistinfo span[data-uid=" + UserInfo.User_ID + "]").data('userdata', UserInfo);
                    }
                    _ThisPage.Page.Chat.ChatScrollToBottom();
                },
                //操作提示语
                OutText:function(data){
                    var User1 = data.User1;
                    var User2 = data.User2;
                    var Text = data.Text;
                    var msg = '';
                    msg += '<li class="enter">';
                    Text = Text.replaceAll("{User1}", _ThisPage.Page.Chat.CommonUtils.getUserName(User1));
                    Text = Text.replaceAll("{User2}", _ThisPage.Page.Chat.CommonUtils.getUserName(User2));
                    msg += Text;
                    msg += '</li>';
                    $("#J_Chatlistinfo").append(msg);
                    if (!User1.Guest) {
                        $("#J_Chatlistinfo span[data-uid=" + User1.User_ID + "]").data('userdata', User1);
                    }
                    if (!User2.Guest) {
                        $("#J_Chatlistinfo span[data-uid=" + User2.User_ID + "]").data('userdata', User2);
                    }
                    _ThisPage.Page.Chat.ChatScrollToBottom();
                },
                //系统提示
                SysText:function (text) {
                    var msg = '';
                    msg += '<li class="enter">' +
                        text +
                        '</li>';
                    $("#J_Chatlistinfo").append(msg);
                    _ThisPage.Page.Chat.ChatScrollToBottom();
                },
                //显示给游客的诱导文字
                GuestText:{
                    Data:{
                        Msg:[
                            ["你是新来的吧，有什么想问我吗？","来了这么久都不理人家，人家好难受..."],
                            ["听说有些艺人晚上偷偷跳舞，你说我晚上来跳舞会不会被巡查抓到？","怎么这么久都不回复我呢？哼，不理你啦！"],
                            ["怎么不理我？","跟我聊聊呗^_^"],
                            ["你好！","在吗？"],
                        ],
                        MsgIndex: 0
                    },
                    Init:function(){
                        if(!$.CommonMainRoom.RoomInfo.Live) return;
                        if(_StateData.IsLogin) return;

                        var index = _ThisPage.Page.Chat.GuestText.Data.MsgIndex = Math.floor(_ThisPage.Page.Chat.GuestText.Data.Msg.length * Math.random());
                        setTimeout(function(){
                            _ThisPage.Page.Chat.GuestText.Out($.CommonMainRoom.RoomAnchorInfo, _ThisPage.Page.Chat.GuestText.Data.Msg[index][0]);
                        }, 3000);
                        setTimeout(function(){
                            _ThisPage.Page.Chat.GuestText.Out($.CommonMainRoom.RoomAnchorInfo, _ThisPage.Page.Chat.GuestText.Data.Msg[index][1]);
                        }, 33000);
                    },
                    Out:function(anchorInfo, text){
                        var msg = '<li><em class="userlev"><img src="'+_VirtualPath.Static+'main/image/common/level/anchor/'+anchorInfo.Level+'.png" alt="22"></em><span class="username" data-uid="'+anchorInfo.User_ID+'">'+anchorInfo.NickName+'</span> <span>对</span> <span class="username" data-uid="0"> 你 </span> <span>说</span>：<span>'+text+'</span></li>';
                        $("#J_Chatlistinfo").append(msg);
                        _ThisPage.Page.Chat.ChatScrollToBottom();
                    }
                },


                //始终保持在底部
                ChatScrollToBottom: function () {
                    $("#J_WebChatList").scrollTop($('#J_Chatlistinfo').height());
                    $("#J_WebChatListPrivate").scrollTop($('#J_ChatlistinfoPrivate').height());
                },
                //公聊 私聊 TAB界面切换 index 0是公聊 1私聊
                ChatSelectTab:function (index) {
                    var tabArr = ["#J_PublicChatTabBtn","#J_PrivateChatTabBtn"];
                    $(tabArr[index]).addClass('on').siblings().removeClass('on');
                    $(".WebChatList").hide().eq(index).show();
                    // Log.Out("ChatSelectTab",index);
                    if(0 == index){
                        // _ThisPage.Page.Chat.Data.ChatUser.id = 0;
                        _ThisPage.Page.Chat.Data.ChatUser.Private = false;
                        _ThisPage.Page.Chat.Data.ChatUser.PrivateTa = false;
                        // _ThisPage.Page.Chat.Data.ChatUser.Receiver = null;
                        $("#J_InputTextWord").attr("placeholder","双手打字，以示清白~");
                    }else if(1 == index){
                        $("#J_ChatNewMsgTip").removeClass('NewMsgRec').fadeOut();
                        if(_ThisPage.Page.Chat.Data.ChatUser.Receiver){
                            _ThisPage.Page.Chat.Data.ChatUser.Private = true;
                            _ThisPage.Page.Chat.Data.ChatUser.PrivateTa = true;
                            $("#J_InputTextWord").attr("placeholder","@ 对 "+_ThisPage.Page.Chat.Data.ChatUser.Receiver.NickName+" 悄悄说");
                        }
                    }
                },
                //关闭表情选择面板
                ChatCloseFaceEmoPanel:function(){
                    $('#J_FaceEmoLayer').hide();
                    $(window).off("click");
                    $("#J_InputTextWord").focus();
                },
                //文字 消息 过滤
                MsgFilter:function (txt) {
                    if(_ThisPage.Page.Chat.Data.Word.length>0){
                        _ThisPage.Page.Chat.Data.Word.forEach(function (value) {
                            // txt = _.replace(txt, value  , _.repeat('*', value.length));
                            txt = txt.replaceAll(value, _.repeat('*', value.length));
                        });
                    }
                    return txt;
                },
                //聊天区 表情符号
                FaceEmo:{
                    //初始化表情面板
                    InitPanel:function () {
                        var UserInfo = $.CommonMainRoom.RoomUserInfo;
                        var _Emoji = '';
                        var _EmoVip = '';
                        var _EmoGuard = '';
                        for (var i=1;i<=56;i++){
                            _Emoji+= '<li><img src="'+_VirtualPath.Static+'main/image/emo/emoji/emoji_'+i+'.png" alt="f'+i+'"></li>';
                        }
                        for (var i=1;i<=24;i++){
                            _EmoVip+= '<li><img src="'+_VirtualPath.Static+'main/image/emo/common/e'+i+'.png" alt="v'+i+'"></li>';
                        }
                        for (var i=1;i<=10;i++){
                            _EmoGuard+= '<li><img src="'+_VirtualPath.Static+'main/image/emo/guard/e'+i+'.png" alt="g'+i+'"></li>';
                        }

                        $("#J_EmoJi").html(_Emoji);
                        $("#J_EmoVip").html(_EmoVip);
                        $("#J_EmoGuard").html(_EmoGuard);

                        //检测表情权限
                        if(!UserInfo.VIP){
                            var _html = '<div class="EmoTip">'+
                                '<div class="filterbg">'+
                                '</div>'+
                                '<a href="/mall/vip/" target="_blank" class="BtnBuy">开通会员</a>'+
                                '</div>'
                            $("#J_EmoVip").append(_html);
                        }
                        if(!UserInfo.RoomGuardian){
                            var _html = '<div class="EmoTip">'+
                                '<div class="filterbg">'+
                                '</div>'+
                                '<a href="javascript:;" class="BtnBuy" id="J_OpenGuard">开通守护</a>'+
                                '</div>'
                            $("#J_EmoGuard").append(_html);
                        }
                    },
                    //表情替换规则
                    FaceEscape:function (UserInfo, text) {
                        function replaceEmo(text){
                            for(var i=1;i<=56;i++){
                                var key = '[f'+i+']';
                                text = text.replaceAll(key, '<img src="'+_VirtualPath.Static+'main/image/emo/emoji/emoji_'+i+'.png"  class="chat-emoticon" />');
                            }
                            return text;
                        }
                        function replaceEmoVIP(text) {
                            for(var i=1;i<=24;i++){
                                var key = '[v'+i+']';
                                text = text.replaceAll(key, '<img src="'+_VirtualPath.Static+'main/image/emo/common/e'+i+'.png" class="chat-emoticon" />');
                            }
                            return text;
                        }
                        function replaceEmoGuard(text) {
                            for(var i=1;i<=10;i++){
                                var key = '[g'+i+']';
                                text = text.replaceAll(key, '<img src="'+_VirtualPath.Static+'main/image/emo/guard/e'+i+'.png"  class="chat-emoticon"/>');
                            }
                            return text;
                        }
                        text = text.replace(/\&/g,'&amp;');
                        text = text.replace(/\</g,'&lt;');
                        text = text.replace(/\>/g,'&gt;');
                        text = text.replace(/\"/g,'&quot;');
                        text = text.replace(/\'/g,'&#039;');
                        // 循环
                        text = replaceEmo(text);
                        if(UserInfo.VIP) text = replaceEmoVIP(text);
                        if(UserInfo.RoomGuardian) text = replaceEmoGuard(text);
                        return text;
                    }
                },
            },
            /**
             * 礼物功能
             */
            Gift:{
                Data:{
                    GiftId:0, // 当前选中的礼物ID
                    GiftListIndex:0, //当前选中的礼物列表索引
                    GiftNum:0, // 当前选中的礼物数量
                    TargetUserId:0, //赠送目标ID
                    // sending:false, //是否 正在赠送中
                    isEffectOn:true, //是否 效果 开启
                    GiftSendBtnTimeout:0, //赠送按钮动画
                    GiftSendBtnInterval:0, //赠送按钮动画
                    IntervalNum:0, //赠送按钮动画
                    CurrTag:null //当前 标签 类型
                },
                //初始化
                Init:function () {
                    _ThisPage.Page.Gift.Data.sending = false;
                    //初始化 送礼 组合效果 间隔检测
                    GiftEffectFactory.CheckDataInit();
                    //初始化连击效果
                    Streamer.Init();
                    //初始化 礼物列表
                    _ThisPage.Page.Gift.InitGiftList(0, 0);
                    _ThisPage.Page.Gift.InitGiftTabEvent();

                    //初始化 赠送对象人 ID,礼物数量
                    _ThisPage.Page.Gift.Data.GiftNum = parseInt($("#J_GiftSendNum").val()); //默认礼物 数量
                    _ThisPage.Page.Gift.Data.TargetUserId = $.CommonMainRoom.RoomAnchorInfo.RoomID; //房间ID就是艺人ID
                    $("#J_GiftReceiveUser").val($.CommonMainRoom.RoomAnchorInfo.NickName); //默认礼物接受人 昵称
                    //添加到赠送对象人 列表
                    _ThisPage.Page.Gift.AddGiftReceiveUserList({
                        User_ID:$.CommonMainRoom.RoomAnchorInfo.RoomID,
                        NickName:$.CommonMainRoom.RoomAnchorInfo.NickName
                    });

                    //初始化房间 送礼历史记录列表【数据未定】
                    // GiftEffectFactory.GiftHistoryListRoomInit( $("#J_GiftHistoryListDiv"), $("#J_GiftHistoryList"), data);
                    // $("#J_GiftHistoryListDiv").perfectScrollbar();


                },
                //初始化礼物按钮事件
                InitGiftTabEvent: function () {
                    //切换 礼物分类 TAB
                    $("#J_GiftTab").off('click', 'li');
                    $("#J_GiftTab").on('click', 'li', function (event) {
                        var index = $(this).index();
                        if (index == 4 && !$.CommonMain.LoginCheck()) {
                            return;
                        }
                        $(this).addClass('active').siblings().removeClass('active');
                        _ThisPage.Page.Gift.InitGiftList(index, 0);
                        _ThisPage.Page.Gift.Data.GiftId = $("#J_GiftList li.GiftItem.active").data('id');
                    });
                    $("#J_GiftSendNum").keyup(function(event) {
                        _val = $(this).val().replace(/[^0-9]\D*$/,"");
                        $(this).val(_val);
                        _ThisPage.Page.Gift.Data.GiftNum = _val;
                    });
                    //选择BoxList礼物数量
                    $("#J_GiftSelectNum").off('click', 'li');
                    $("#J_GiftSelectNum").on('click', 'li', function (event) {
                        _ThisPage.Page.Gift.Data.GiftNum = $(this).attr("data-num");
                        $("#J_GiftSendNum").val(_ThisPage.Page.Gift.Data.GiftNum);

                        $('#J_GiftSendNum').removeClass('active');
                        $("#J_GiftSelectNum").hide();
                        $('#J_GiftArrowEvent').removeClass('ZsArrowDown').addClass('ZsArrowUp')

                    });
                    //礼物赠送数量
                    $('#J_GiftSendNum,#J_GiftArrowEvent').off('click');
                    $('#J_GiftSendNum,#J_GiftArrowEvent').on('click',function(event) {
                        event.stopImmediatePropagation();
                        if ($("#J_GiftSendNum").hasClass('active')) {
                            _ThisPage.Page.Gift.GiftListCountSelect.Hide();
                        } else {
                            _ThisPage.Page.Gift.GiftListCountSelect.Show();
                        }
                    });

                    //选择BoxList礼物对象
                    $("#J_GiftSelectUser").off('click', 'li');
                    $("#J_GiftSelectUser").on('click', 'li', function (event) {
                        _ThisPage.Page.Gift.Data.TargetUserId = $(this).attr("data-uid");
                        $("#J_GiftReceiveUser").val($(this).text());

                        $('#J_GiftSendNum').removeClass('active');
                        $("#J_GiftSelectUser").hide();
                        $('#J_GiftArrowEvent').removeClass('ZsArrowDown').addClass('ZsArrowUp')

                    });
                    //礼物赠送对象
                    $('#J_GiftReceiveUser').off('click');
                    $('#J_GiftReceiveUser').on('click',function(event) {
                        event.stopImmediatePropagation();
                        if ($("#J_GiftSelectUser").hasClass('active')) {
                            _ThisPage.Page.Gift.GiftListUserSelect.Hide();
                        } else {
                            _ThisPage.Page.Gift.GiftListUserSelect.Show();
                        }
                    });


                    //点击赠送按钮
                    $("#J_GiftSendBtn").off('click');
                    $("#J_GiftSendBtn").on('click',function(event) {
                        if (!$.CommonMain.LoginCheck()) return ;
                        if(_ThisPage.Page.Gift.Data.sending) return ;
                        if(_ThisPage.Page.Gift.Data.GiftId == 0){
                            _ThisPage.Page.CommonUitls.Tip("请先选择一个礼物!");
                            return;
                        }
                        var BuyMode = (_ThisPage.Page.Gift.Data.CurrTag == "Package") ? 2 : 1; //1只购买 2只包裹
                        // _ThisPage.Page.Gift.Data.TargetUserId = '';

                        //如果是包裹礼物，减去数量。
                        // if(_ThisPage.Page.Gift.Data.CurrTag == "Package"){
                        //     var giftNum = Number($("#package-giftid-"+_ThisPage.Page.Gift.Data.GiftId).text());
                        //     if(giftNum < _ThisPage.Page.Gift.Data.GiftNum){
                        //         _ThisPage.Page.CommonUitls.Tip("礼物数量不够，请重新选择数量！");
                        //         return;
                        //     }
                        //
                        //     var giftCount = giftNum-_ThisPage.Page.Gift.Data.GiftNum;
                        //     $("#package-giftid-"+_ThisPage.Page.Gift.Data.GiftId).text( giftCount );
                        //     if(giftCount <= 0){ //为零时删除包裹礼物
                        //         $("#J_GiftList li[data-id="+_ThisPage.Page.Gift.Data.GiftId+"]").remove();
                        //         _ThisPage.Page.Gift.Data.GiftId = null;
                        //     }
                        // }

                        Log.Out("赠送礼物==========》", [
                            "GiftId:"+_ThisPage.Page.Gift.Data.GiftId,
                            "GiftNum:"+_ThisPage.Page.Gift.Data.GiftNum,
                            "TargetUserId:"+_ThisPage.Page.Gift.Data.TargetUserId,
                            "BuyMode:"+BuyMode]);
                        _ThisPage.Page.Gift.Data.sending = true;
                        $.CommonMainRoom.SocketEmit.Gift(_ThisPage.Page.Gift.Data.GiftId, _ThisPage.Page.Gift.Data.GiftNum, _ThisPage.Page.Gift.Data.TargetUserId, BuyMode);

                    });
                },
                //初始化礼物列表
                InitGiftList:function (index, GiftListIndex) {
                    var tagType = [
                        ["Hot"],
                        ["Advanced"],
                        ["Luxury"],
                        ["Exclusive"],
                        ["Package"]
                    ];
                    _ThisPage.Page.Gift.Data.CurrTag = tagType[index];
                    Log.Out("包裹数据", $.CommonMainRoom.UserPackage);
                    var gift = (_ThisPage.Page.Gift.Data.CurrTag == "Package") ? _.filter($.CommonMainRoom.UserPackage, {Item_Type:"Gift"}) : _.filter(_PageData.Commodity.Gift.Data, {Tag: _ThisPage.Page.Gift.Data.CurrTag});

                    var styleName = "";
                    var GiftList = "";
                    if (gift.length <= 0) {
                        GiftList += '<li class="noResult">';
                        GiftList += ' 暂无！';
                        GiftList += '</li>';
                    }
                    for(var i=0; i<gift.length; i++){
                        var Value = (_ThisPage.Page.Gift.Data.CurrTag == "Package") ? gift[i].Item_Info : gift[i];
                        if(_ThisPage.Page.Gift.Data.CurrTag == "Package") Value.Num = gift[i].Num; //如果是包裹礼物，添加数量。
                        var index = (_ThisPage.Page.Gift.Data.CurrTag == "Package") ? GiftListIndex : 0;
                        if(i == index){ // 礼物列表 设置 默认第一个选中状态
                            styleName = "GiftItem active";
                            _ThisPage.Page.Gift.Data.GiftListIndex = (Value.id == _ThisPage.Page.Gift.Data.GiftId) ? _ThisPage.Page.Gift.Data.GiftListIndex : i;
                            _ThisPage.Page.Gift.Data.GiftId = Value.id;//默认选中的 礼物ID
                        }else{
                            styleName = "GiftItem";
                        }
                        GiftList += '<li class="'+styleName+'" data-id=' + Value.id + ' data-name = ' + Value.Name + ' data-price = ' + Value.Price + '>';
                        if(_ThisPage.Page.Gift.Data.CurrTag == "Package"){
                            GiftList +='<span class="ico-package-num" id="package-giftid-'+Value.id+'">'+Value.Num+'</span>';
                        }
                        else
                        {
                            if(_.includes(Value.Tag, "Lucky")){
                                //幸运礼物 角标
                                GiftList +='<i class="ico-lucky"></i>';
                            }
                            if(_.includes(Value.Tag, "WeekStar")){
                                //礼物周星 角标
                                GiftList +='<i class="ico-weekstar"></i>';
                            }
                            if(_.includes(Value.Tag, "Activity")){
                                //礼物活动 角标
                                GiftList +='<i class="ico-activity"></i>';
                            }
                        }

                        GiftList += '<img src=' + _VirtualPath.Static + 'main/image/room/gift/' + Value.id + '.png alt=' + Value.Name + '>';
                        GiftList += '</li>';
                    }
                    $("#J_GiftList").empty().append(GiftList);

                    //点击 礼物 ITEM
                    $("#J_GiftList").off('click');
                    $("#J_GiftList").on('click', 'li', function(event) {
                        $(this).addClass('active').siblings().removeClass('active');
                        _ThisPage.Page.Gift.Data.GiftId = parseInt($(this).attr("data-id"));
                        _ThisPage.Page.Gift.Data.GiftListIndex = parseInt($(this).index());
                    });

                    /**
                     * 礼物鼠标移动事件 Tips
                     */
                    $("#J_GiftList li[data-id]").off('mouseover');
                    $("#J_GiftList li[data-id]").on('mouseover', function (event) {
                        // $(this).addClass('active').siblings().removeClass('active');
                        var _Obj = {}
                        _Obj.name = $(this).attr('data-name');
                        _Obj.src = $(this).find('img').attr('src');
                        _Obj.price = $(this).attr('data-price');

                        $("#J_GiftPopTip ._thumb").attr('src', _Obj.src);
                        $("#J_GiftPopTip .name").text(_Obj.name);
                        $("#J_GiftPopTip .price").text(_Obj.price + "金币");


                        $("#J_GiftPopTip").show();
                    });
                    $("#J_GiftList li[data-id]").off('mouseout');
                    $("#J_GiftList li[data-id]").on('mouseout', function (event) {
                        $("#J_GiftPopTip").hide();
                    });

                    var left;
                    var _lens = gift.length;
                    var obw = $("#J_GiftContIntro").outerWidth();
                    var bw = 10 * 48;

                    var pageTotal = Math.floor(_lens / 11) + 1;
                    var pageIndex = 1;

                    $("#J_GiftList").css({
                        'width': _lens * 48,
                        'left': 0,
                        'position': 'absolute'
                    });

                    //礼物左移动
                    $("#J_GiftRightBtn").off('click');
                    $("#J_GiftRightBtn").on('click', function (event) {
                        if (pageIndex + 1 > pageTotal) return;
                        pageIndex++;
                        $("#J_GiftList").animate({ left:-((pageIndex - 1) * bw)+"px" }, 500, "swing");
                    });
                    //礼物右移动
                    $("#J_GiftLeftBtn").off('click');
                    $("#J_GiftLeftBtn").on('click', function (event) {
                        if (pageIndex - 1 < 1) return;
                        pageIndex--;
                        $("#J_GiftList").animate({ left:-((pageIndex - 1) * bw)+"px" }, 500, "swing");
                    });
                },
                //礼物 数量 选择
                GiftListCountSelect:{
                    Show:function () {
                        $("#J_GiftSendNum").addClass('active');
                        $("#J_GiftSelectNum").show();
                        $('#J_GiftArrowEvent').removeClass('ZsArrowUp').addClass('ZsArrowDown');
                        setTimeout(function(){
                            $(window).on("click",function (e) {
                                e.stopImmediatePropagation();
                                _ThisPage.Page.Gift.GiftListCountSelect.Hide();
                            })
                        },10);
                    },
                    Hide:function () {
                        $("#J_GiftSendNum").removeClass('active');
                        $("#J_GiftSelectNum").hide();
                        $('#J_GiftArrowEvent').removeClass('ZsArrowDown').addClass('ZsArrowUp');
                        $(window).off("click");
                    }
                },
                //礼物 赠送对象 选择
                GiftListUserSelect:{
                    Show:function () {
                        $("#J_GiftSelectUser").show();
                        setTimeout(function(){
                            $(window).on("click",function (e) {
                                e.stopImmediatePropagation();
                                _ThisPage.Page.Gift.GiftListUserSelect.Hide();
                            })
                        },10);
                    },
                    Hide:function () {
                        $("#J_GiftSelectUser").hide();
                        $(window).off("click");
                    }
                },
                //礼物赠送 返回 结果 temp
                RoomGiftGiveResult:function (data) {//data不包含Data
                    //为数据兼容做的
                    var giftData = {
                        Count:data.GiftCount,
                        GiftStreamer:data.GiftStreamer,
                        Gift_ID:data.GiftInfo.id,
                        GiftName:data.GiftInfo.Name,
                        // Gift_Pond_Amt:data.GiftPond ? data.GiftPond.Amt : null,//获取值为null,则原数据值不变
                        // Gift_Pond_TriggerAmt:data.GiftPond ? data.GiftPond.BurstAmt : null,//获取值为null,则原数据值不变
                        Num:data.GiftNum,
                        UserInfo:data.RoomUserInfo,
                        UserInfo_Gift:(data.RoomUserInfo_Gift) ? data.RoomUserInfo_Gift : data.RoomAnchorInfo,
                        RoomAnchor:(data.RoomUserInfo_Gift) ? false : true,
                        RoomAnchorInfo:$.CommonMainRoom.RoomAnchorInfo
                    };
                    giftData.UserInfo_Gift.RoomAnchor = true;
                    //显示礼物历史记录
                    GiftEffectFactory.GiftHistoryList( $("#J_GiftHistoryListDiv"), $("#J_GiftHistoryList"), giftData);
                    $("#J_GiftHistoryListDiv").perfectScrollbar();

                    // //更新自己的等级经验...
                    // _ThisPage.RoomUtils.UpdateSelfExpLevel(data);
                    // //更新对方的等级经验...
                    // _ThisPage.RoomUtils.UpdateOtherExpLevel(data);
                    // //更新艺人的等级经验...
                    // _ThisPage.RoomUtils.UpdateAnchorExpLevel(data);
                    if( !_ThisPage.Page.Gift.Data.isEffectOn ){
                        GiftEffectFactory._ClearMountData();
                        GiftEffectFactory._ClearGiftEffectData();
                        return ;
                    }

                    var isSwfGift = (data.GiftInfo != null && data.GiftInfo.EffectDuration != undefined);

                    if(isSwfGift){
                        GiftEffectFactory.ShowMount(data, "gift");//显示 礼物swf动画效果
                    }

                    if(!isSwfGift){ //礼物效果
                        var giftCount = data.Num;
                        var imgUrl = _VirtualPath.Static+"/main/image/room/gift/"+data.GiftInfo.id+".png";
                        var giftGroupEffectCount = [{n:10},{n:66},{n:99},{n:188},{n:520},{n:1314}];//组合效果 礼物数量
                        var effectGroupIndex = _.findIndex(giftGroupEffectCount, ["n",giftCount]);
                        if(effectGroupIndex != -1){
                            //礼物组合特效
                            // GiftEffectFactory.ShowEffect( $('#J_GiftGroupEffect'), effectGroupIndex, imgUrl, 2 );
                        }else{
                            //礼物抛出效果
                            //GiftEffectFactory.GiftThrow( '#J_GiftThrowEffect', imgUrl, giftCount );
                        }
                    }

                    //显示连击效果 JS
                    // var o = {};
                    // o.Count = data.GiftCount;
                    // o.GiftId = data.GiftInfo.id;
                    // o.GiftName = data.GiftInfo.Name;
                    // o.UserId = data.RoomUserInfo.User_ID;
                    // o.NickName = data.RoomUserInfo.NickName;
                    // o.GiftStreamer = data.GiftStreamer;
                    // o.Num = data.GiftNum;
                    // Log.Out("流光", o);
                    // Streamer.Data.Arr.push( o );
                    
                    //显示流光效果 Flash
                    var o = {};
                    o.UserId = data.RoomUserInfo.User_ID;
                    o.NickName = data.RoomUserInfo.NickName;
                    o.GiftId = data.GiftInfo.id;
                    o.GiftName = data.GiftInfo.Name;
                    o.GiftCount = data.GiftCount;
                    o.GiftNum = data.GiftNum;
                    o.Streamer = data.GiftStreamer;
                    onJsToAs({type:"streamer_add_data", data:o});
                    
                    //幸运礼物暴奖文字
                    if(data.LuckyCoin > 0){
                        var LuckyStr = "";
                        for(var i=0; i<data.MultipleList.length; i++){
                            var LuckyData = data.MultipleList[i];
                            LuckyStr += LuckyData.Multiple+'倍'+LuckyData.Count+'次，';
                        }
                        _ThisPage.Page.Chat.SysText('<span class="ChatSysTips">恭喜 '+_ThisPage.Page.Chat.CommonUtils.getUserName(data.RoomUserInfo)+' 送出 '+data.GiftNum+'个“'+data.GiftInfo.Name+'” 喜中 '+LuckyStr+'共获得'+data.LuckyCoin+'金币！</span>');
                    }
                },
                //显示赠送按钮 倒计时 动画
                ShowGiftBtnAnimation:function () {
                    $("#J_GiftSendBtnProgress").show();
                    $("#J_GiftSendBtnProgressNum").show();
                    $("#J_GiftSendBtnProgressText").hide();
                    if($("#J_GiftSendBtnProgress").hasClass("GiftSendBtnProgress")){
                        $("#J_GiftSendBtnProgress").removeClass("GiftSendBtnProgress");
                    }

                    _ThisPage.Page.Gift.Data.IntervalNum = 4;
                    $("#J_GiftSendBtnProgressNum").text(_ThisPage.Page.Gift.Data.IntervalNum);

                    clearTimeout(_ThisPage.Page.Gift.Data.GiftSendBtnTimeout);
                    _ThisPage.Page.Gift.Data.GiftSendBtnTimeout = setTimeout(function(){$("#J_GiftSendBtnProgress").addClass("GiftSendBtnProgress")},1);

                    clearInterval(_ThisPage.Page.Gift.Data.GiftSendBtnInterval);
                    _ThisPage.Page.Gift.Data.GiftSendBtnInterval = setInterval(function () {
                        _ThisPage.Page.Gift.Data.IntervalNum--;
                        $("#J_GiftSendBtnProgressNum").text(_ThisPage.Page.Gift.Data.IntervalNum);
                        if(_ThisPage.Page.Gift.Data.IntervalNum<=0){
                            clearInterval(_ThisPage.Page.Gift.Data.GiftSendBtnInterval);
                            $("#J_GiftSendBtnProgress").hide();
                            $("#J_GiftSendBtnProgressNum").hide();
                            $("#J_GiftSendBtnProgressText").show();
                            // _ThisPage._TempData.GiftData.sending = false;
                        }
                    },1000);
                },
                //添加赠送对象列表
                AddGiftReceiveUserList:function(UserInfo){
                    var html =  '<li class="item" data-uid="'+UserInfo.User_ID+'">' +
                        '<span>'+UserInfo.NickName+'</span>' +
                        '</li>';
                    if($("#J_GiftSelectUser > .GiftNumStyle li[data-uid="+UserInfo.User_ID+"]").length <= 0){
                        $("#J_GiftSelectUser > .GiftNumStyle").append(html);
                    }
                    _ThisPage.Page.Gift.Data.TargetUserId = UserInfo.User_ID;
                    $("#J_GiftReceiveUser").val(UserInfo.NickName);
                },
                //更新包裹礼物
                UpdateUserPackage:function (dataList) {
                    if(_ThisPage.Page.Gift.Data.CurrTag == "Package"){
                        _ThisPage.Page.Gift.InitGiftList(4, _ThisPage.Page.Gift.Data.GiftListIndex);
                    }
                }
            },
            /**
             * 守护功能
             */
            Guardian:{
                Data:{
                    id: ""
                },
                Init:function (data) {
                    // 【暂时缺少数据】
                    //Init构造守护列表
                    // _.forEach(data.List, function (Value) {
                    //     _ThisPage.Page.Guardian.AddGuardListItem(Value, 1);
                    // });
                    // $("#J_GuardNum").text(data.List.length || '-');
                    // $("#J_GuardList").perfectScrollbar();

                    //初始化购买守护按钮界面
                    $('#J_GuardianBuy,#J_GuardianAdd,#J_OpenGuard').off("click");
                    $('#J_GuardianBuy,#J_GuardianAdd,#J_OpenGuard').on("click", function () {
                        if (!$.CommonMain.LoginCheck()) {
                            return;
                        }

                        var _Param = {};
                        _Param.left = $("#J_MR_Video").offset().left + $("#J_MR_Video").width()/2;
                        // _Param.width = $("#J_MR_Video").width();
                        _Param.width = $("#J_GuardPop").innerWidth()/2;
                        _Param.height = $("#J_GuardPop").innerHeight()/2;

                        $("#J_GuardPop").css({
                            "left":_Param.left,
                            "margin-left":(-_Param.width),
                            "top":"40%",
                            "margin-top":(-_Param.height)
                        }).show();
                    });

                    $("#J_GuardPop a.b-close").off('click');
                    $("#J_GuardPop a.b-close").on('click', function (e) {
                        $("#J_GuardPop").hide();
                    });
                    $("#J_GuardType").off('click');
                    $("#J_GuardType").on('click', '.guardTime', function (event) {
                        var index = $(this).index() - 1;
                        $(this).addClass('active').siblings().removeClass('active');
                        $("#J_GuardPrice").text(_PageData.Commodity.Guardian.Data[index].Price);
                        $("#J_GuardPrice2").text(_PageData.Commodity.Guardian.Data[index].Price*2);
                        _ThisPage.Page.Guardian.Data.id = _PageData.Commodity.Guardian.Data[index].id;
                    });
                    //默认守护价格
                    $("#J_GuardPrice").text(_PageData.Commodity.Guardian.Data[0].Price);
                    $("#J_GuardPrice2").text(_PageData.Commodity.Guardian.Data[0].Price*2);
                    _ThisPage.Page.Guardian.Data.id = _PageData.Commodity.Guardian.Data[0].id;
                    //购买按钮事件
                    $(".b-button").off('click');
                    $(".b-button").on('click', function (event) {
                        if($.CommonMainRoom.RoomUserInfo.RoomAnchor){
                            _ThisPage.Page.CommonUitls.Tip("您不能给自己开通守护！");
                            return ;
                        }
                        $.CommonMainRoom.SocketEmit.Guardian(_ThisPage.Page.Guardian.Data.id);
                    });
                    //加载数据
                    _ThisPage.Page.Guardian.LoadGuardianList();
                    //守护滚动条
                    $("#J_GuardList").perfectScrollbar();
                },
                LoadGuardianList:function () {
                    $.getJSON(_VirtualPath.Main + "ajax/user.user-anchor-guardian.list-guardian", {
                        User_ID:$.CommonMainRoom.RoomInfo.RoomID
                    }, function (json) {
                        if (json.flag !== 0) {
                            _ThisPage.Page.CommonUitls.Tip("Error "+json.msg+" "+json.flag);
                            return;
                        }
                        // Log.Out("守护列表数据", json.data);

                        var arr = json.data;
                        $("#J_GuardNum").text(arr.length);
                        arr.forEach(function (value) {
                            _ThisPage.Page.Guardian.AddGuardListItem(value);
                        });
                    });
                },
                /**
                 * 添加守护ITEM到 列表
                 * @param data  itemData
                 * @param type  为兼容数据格式
                 * @constructor
                 */
                AddGuardListItem: function (data) {
                    var expire = moment(data.Guardian_Expire);
                    var Guardian_ExpireDay = expire.diff(moment(), 'days');

                    if (data.User_ID == $("#J_GuardList li[data-uid=" + data.User_ID + "]").attr("data-uid")) {
                        $("#J_GuardList li[data-uid=" + data.User_ID + "]").find('.GuardTime').text(Guardian_ExpireDay + "天");
                        if (data.Guardian_Mode == "YEAR") {
                            $('<span class="GuardYear"></span>').insertAfter($("#J_GuardList li[data-uid=" + data.User_ID + "]").find('.GuardTime'));
                        }
                        return;
                    }
                    var g = "";
                    g += '<li data-uid =' + data.User_ID + ' >';
                    g += '<a href="javascript:;" class="Intropic">';
                    g += '<img src="' + _ThisPage.Page.CommonUitls.GetUserHand(data.User_ID, "54.54") + '" alt="">';
                    g += '<span class="GuardFilter"></span>';
                    g += '<b class="GuardTxt">剩</b>';
                    g += '<span class="GuardTime">' + Guardian_ExpireDay + '天</span>';
                    if (data.Guardian_Mode == "YEAR") {
                        g += '<span class="GuardYear"></span>';
                    }
                    g += '</a>';
                    g += '<h3>' + data.NickName + '</h3>';
                    g += '</li>';

                    $("#J_GuardList").prepend(g);
                },
                //守护购买结果
                BuyResult: function (data) {
                    var userInfo = {
                        Create_Date: data.CreateDate,
                        Create_IP: "",
                        EXP: data.RoomUserInfo.EXP,
                        Guardian_Expire: data.RoomUserInfo.RoomGuardian_Expire,
                        Guardian_ID: data.GuardianInfo.id,
                        Guardian_Mode: data.GuardianInfo.Mode,
                        Guardian_Name: data.GuardianInfo.Name,
                        IsAnchor: data.RoomUserInfo.IsAnchor,
                        IsFamily: data.RoomUserInfo.IsFamily,
                        NickName: data.RoomUserInfo.NickName,
                        RealName: "",
                        User_ID: data.RoomUserInfo.User_ID,
                        User_ID_Guardian: data.RoomUserInfo.RoomID,
                        VIP: data.RoomUserInfo.VIP,
                        VIP_Expire: data.RoomUserInfo.VIP_Expire
                    };
                    _ThisPage.Page.Guardian.AddGuardListItem(userInfo);
                    $("#J_GuardPop").hide();
                },
                //守护更新通知
                UpdateNotify: function (data) {
                    //更新人员列表守护图标
                    if (data.RoomGuardian && data.RoomGuardian_Mode == "MONTH") {
                        if ($("#J_UserList li[data-uid=" + data.User_ID + "] img[src$='Ico-guard-year.png']").length > 0) {
                            $("#J_UserList li[data-uid=" + data.User_ID + "] img[src$='Ico-guard-year.png']").remove();
                        }
                        if ($("#J_UserList li[data-uid=" + data.User_ID + "] img[src$='Ico-guard-month.png']").length <= 0) {
                            $("#J_UserList li[data-uid=" + data.User_ID + "]").append('<span><img src="' + _VirtualPath.Static + '/main/image/room/icon/Ico-guard-month.png" alt="月守护"></span>');
                        }
                    }

                    if (data.RoomGuardian && data.RoomGuardian_Mode == "YEAR") {
                        if ($("#J_UserList li[data-uid=" + data.User_ID + "] img[src$='Ico-guard-month.png']").length > 0) {
                            $("#J_UserList li[data-uid=" + data.User_ID + "] img[src$='Ico-guard-month.png']").remove();
                        }
                        if ($("#J_UserList li[data-uid=" + data.User_ID + "] img[src$='Ico-guard-year.png']").length <= 0) {
                            $("#J_UserList li[data-uid=" + data.User_ID + "]").append('<span><img src="' + _VirtualPath.Static + '/main/image/room/icon/Ico-guard-year.png" alt="年守护"></span>');
                        }
                    }

                    //更新房间通知
                    var _Level = data.RoomAnchor ? "anchor/" + data.Level : "user/" + data.Level;
                    var msg = '';
                    msg += '<li class="sys">';
                    msg += '<span class="welcome">恭喜</span>';
                    msg += '<em class="userlev"><img src="' + _VirtualPath.Static + 'main/image/common/level/' + _Level + '.png" alt="' + data.Level + '"></em>';
                    msg += '<span class="username" data-uid=' + data.User_ID + '>' + data.NickName + '</span>';

                    if (data.VIP > 0) {
                        msg += '<em class="isVip"><img src="' + _VirtualPath.Static + 'main/image/room/icon/vip.png" alt="' + data.VIP + '"></em>';
                    }
                    if (data.RoomAdmin) {
                        msg += '<em class="isAdmin"><img src="' + _VirtualPath.Static + 'main/image/room/icon/Ico-admin.png" alt="管理"></em>';
                    }
                    if (data.RoomGuardian && data.RoomGuardian_Mode == "MONTH") {
                        msg += '<em class="isGuard"><img src="' + _VirtualPath.Static + 'main/image/room/icon/Ico-guard-month.png" alt="月守护"></em>';
                    }
                    if (data.RoomGuardian && data.RoomGuardian_Mode == "YEAR") {
                        msg += '<em class="isGuard"><img src="' + _VirtualPath.Static + 'main/image/room/icon/Ico-guard-year.png" alt="年守护"></em>';
                    }
                    msg += '<span>成为该房间的守护神，吾身为剑，守你万事平安，吾魂为盾，护你岁月静好～ </span>';
                    msg += '</li>';

                    $("#J_Chatlistinfo").append(msg);

                    if (!data.Guest) {
                        //为兼容聊天区 数据格式
                        var UserInfo = {};
                        UserInfo.EXP = data.EXP;
                        UserInfo.EXP_Next = data.EXP_Next;
                        UserInfo.Family_ID = data.Family_ID;
                        UserInfo.GiftLast = [];
                        UserInfo.Guest = data.Guest;
                        UserInfo.IsAnchor = data.IsAnchor;
                        UserInfo.IsFamily = data.IsFamily;
                        UserInfo.Level = data.Level;
                        // UserInfo.EXP_Difference
                        UserInfo.Level_Next = data.Level_Next;
                        UserInfo.NickName = data.NickName;
                        UserInfo.Pomelo = data.Pomelo;
                        UserInfo.RoomAdmin = data.RoomAdmin;
                        UserInfo.RoomAnchor = data.RoomAnchor;
                        UserInfo.RoomBlack = data.RoomBlack;
                        UserInfo.RoomBlack_Shutup_Expire = data.RoomBlack_Shutup_Expire;
                        UserInfo.RoomGuardian = data.RoomGuardian;
                        UserInfo.RoomGuardianExpire = data.RoomGuardian_Expire;
                        UserInfo.RoomGuardianExpireDay = data.RoomGuardian_ExpireDay
                        UserInfo.RoomGuardianMode = data.RoomGuardian_Mode;
                        UserInfo.User_ID = data.User_ID;
                        UserInfo.VIP = data.VIP;
                        UserInfo.VIP_Expire = data.VIP_Expire;
                        // $("#J_Chatlistinfo span[data-uid=" + data.Data.User_ID + "]").data('userdata', data.Data);
                        $("#J_Chatlistinfo span[data-uid=" + data.User_ID + "]").data('userdata', UserInfo);
                    }
                    _ThisPage.Page.Chat.ChatScrollToBottom();

                }
            },
            /**
             * 人员列表
             */
            UserList:{
                Data:{
                    UserCount:0, //人员列表人数，官方人员需要数量不要显示在里面。
                    ListArr:[], //人员列表数据
                    AdminListArr:[], //管理列表
                },
                Init:function () {
                    //点击（用户列表）人员，管理者TAB切换
                    $("#J_NavTab").off('click');
                    $("#J_NavTab").on('click', 'li', function (event) {
                        var index = $(this).index();
                        $(this).addClass('active').siblings().removeClass('active');
                        $("#J_UserListCont .ChatList").eq(index).show().siblings().hide();
                        if(index == 0){
                            _ThisPage.Page.UserList.LoadList();
                        }else if(index == 1){
                            _ThisPage.Page.UserList.Admin.LoadList();
                        }
                    });
                    $(".userCont").perfectScrollbar();
                },
                //加载用户列表
                LoadList:function () {
                    $.CommonMainRoom.SocketEmit.UserList();
                },
                //加载完成的用户列表
                Result:function (arr) {
                    // //初始化人员列表
                    // $("#J_UserTotal").text(data.UserList.length); //用户总人数
                    // $("#J_AdminTotal").text(data.Admin.List.length); //用户列表 管理人数
                    // $("#js_userlist").perfectScrollbar();
                    if(arr.length > 0){
                        $("#J_UserList").empty();
                    }
                    var UserCount = 0;
                    this.Data.ListArr = arr;
                    this.Data.ListArr.forEach(function (value) {
                        //官方人员 列表中不显示
                        if(!value.IsAdmin){
                            _ThisPage.Page.UserList.AddUserItem(value);
                            UserCount++;
                        }
                    });
                    $("#J_UserTotal").text( UserCount );
                    // _ThisPage.Page.UserList.Data.ListArr = null;

                    //初始化机器人
                    _ThisPage.Page.RobotManage.Init();
                },
                //添加新用户到用户列表
                AddUserItem: function (data, isRobot) {
                    var _Path = data.RoomAnchor ? "anchor" : "user";
                    var _Level = data.RoomAnchor ? $.CommonMainRoom.RoomAnchorInfo.Level : data.Level;
                    var userItem = '<li class="item ' + _Path + '" data-uid="' + data.User_ID + '">';
                    // if ( !(data.Guest || isRobot) ) {
                    //     userItem += '<em class="J_UserLevelIcon"><img src=' + _VirtualPath.Static + 'main/image/common/level/' +_Path +"/"+ _Level + '.png alt="' + _Level + '"></em>';
                    // }
                    // if (data.VIP > 0) {
                    //     userItem += '<span><img src=' + _VirtualPath.Static + 'main/image/room/icon/vip.png alt="VIP"></span>';
                    // }
                    // if(data.IsAdmin) {
                    //     userItem += '<span><img src=' + _VirtualPath.Static + 'main/image/room/icon/Ico-official.png alt="官方"></span>';
                    // }
                    // if (data.RoomGuardian && data.RoomGuardian_Mode == "MONTH") {
                    //
                    //     userItem += '<span><img src=' + _VirtualPath.Static + 'main/image/room/icon/Ico-guard-month.png alt="月守护"></span>';
                    // }
                    // if (data.RoomGuardian && data.RoomGuardian_Mode == "YEAR") {
                    //
                    //     userItem += '<span><img src=' + _VirtualPath.Static + 'main/image/room/icon/Ico-guard-year.png alt="年守护"></span>';
                    // }
                    // if (data.RoomAdmin) {
                    //     userItem += '<span><img src=' + _VirtualPath.Static + 'main/image/room/icon/Ico-admin.png alt="管理"></span>';
                    // }
                    // userItem += '<span class="name">' + data.NickName + '</span>';
                    userItem += _ThisPage.Page.Chat.CommonUtils.getUserName(data, false);
                    userItem += '</li>';

                    //加入机器人 到列表
                    // if(isRobot){
                    //     $("#J_RobotList").append(userItem);
                    //     $("#J_RobotList li[data-uid=" + data.User_ID + "]").data("key", data);
                    //
                    //     $("#J_UserTotal").text(_ThisPage.RoomData.UserList.length);
                    //     $("#J_AdminTotal").text(_ThisPage.RoomData.Admin.List.length);
                    //
                    //     $("#J_RobotList li[data-uid=" + data.User_ID + "]").off('click');
                    //     $("#J_RobotList li[data-uid=" + data.User_ID + "]").on('click', function (e) {
                    //         // if (!$.CommonMain.LoginCheck()) return ;
                    //         var _left = $(this).offset().left+8;
                    //         var _top = $(this).offset().top + $(this).height() + 8;
                    //         $("#J_UserCardPop").data('userinfo', data);
                    //         $("#J_UserCardPop").css({
                    //             left: _left,
                    //             top: _top,
                    //             zIndex:1000
                    //         }).fadeIn();
                    //         $("#J_UserCardPop .MCard-Arrow").css({
                    //             left:"12px"
                    //         })
                    //         _ThisPage.RoomUtils.ChatCreateMiniCard(data);
                    //     });
                    //     return ;
                    // }

                    // //客户端插入排序
                    // //加入真实用户 到列表
                    // if(data.RoomAnchor){
                    //     $("#J_UserList").prepend(userItem); //艺人
                    // }else if(data.Guest){
                    //     $("#J_UserList").append(userItem); //游客
                    // }else{
                    //     //其他注册用户
                    //     var targetUserId = -1;
                    //     var listChild = $("#J_UserList li");
                    //
                    //     if(listChild.length <= 0){
                    //         $("#J_UserList").append(userItem);
                    //     }else{
                    //         for(var i=0; i<listChild.length; i++){
                    //             var childData = listChild.eq(i).data("key");
                    //             if(childData != null && !childData.RoomAnchor && childData.EXP <= data.EXP){
                    //                 targetUserId = childData.User_ID;
                    //                 break;
                    //             }
                    //         }
                    //
                    //         if(targetUserId > 0){
                    //             $("#J_UserList li[data-uid="+targetUserId+"]").before(userItem);
                    //         }else{
                    //             $("#J_UserList").append(userItem);
                    //         }
                    //     }
                    // }

                    //服务端排序
                    if(isRobot){
                        $("#J_RobotList").append(userItem);
                    }else{
                        $("#J_UserList").append(userItem);
                    }
                    // $("#J_UserList li[data-uid=123]").before('<li id="li4">4</li>'); //加在元素前面
                    // $("#J_UserList li[data-uid=123]").after('<li id="li5">5</li>'); //加在元素后面

                    $("#J_UserList li[data-uid=" + data.User_ID + "]").data("key", data);
                    $("#J_UserList li[data-uid=" + data.User_ID + "]").off('click');
                    $("#J_UserList li[data-uid=" + data.User_ID + "]").on('click', function (e) {
                        //  if (!$.CommonMain.LoginCheck()) return ;
                        var _left = $(this).offset().left+8;
                        var _top = $(this).offset().top + $(this).height() + 8;
                        $("#J_UserCardPop").data('userinfo', data);
                        $("#J_UserCardPop").css({
                            left: _left,
                            top: _top,
                            zIndex:1000
                        }).fadeIn();
                        $("#J_UserCardPop .MCard-Arrow").css({
                            left:"12px"
                        })
                        _ThisPage.Page.CommonUitls.CreateUserInfoMiniCard(data);
                    });
                },
                //管理员列表
                Admin:{
                    LoadList:function(){
                        $.CommonMainRoom.SocketEmit.AdminList();
                    },
                    Result:function(arr){
                        $("#J_AdminTotal").text(arr.length);
                        if(arr.length > 0){
                            $("#J_AdminList").empty();
                        }
                        arr.forEach(function (value) {
                            // value.RoomAdmin = true;//测试用管理员
                            // Log.Out("管理员列表Item", value);
                            _ThisPage.Page.UserList.Admin.AddUserItem(value);
                        });
                    },
                    //添加新用户到用户列表
                    AddUserItem: function (data, isRobot) {
                        data.RoomAdmin = true;
                        var _Path = data.RoomAnchor ? "anchor" : "user";
                        var _Level = data.RoomAnchor ? $.CommonMainRoom.RoomAnchorInfo.Level : data.Level;
                        var userItem = '<li class="item ' + _Path + '" data-uid="' + data.User_ID + '">';
                        if ( !(data.Guest || isRobot) ) {
                            userItem += '<em class="J_UserLevelIcon"><img src=' + _VirtualPath.Static + 'main/image/common/level/' +_Path +"/"+ _Level + '.png alt="' + _Level + '"></em>';
                        }
                        if (data.VIP > 0) {
                            userItem += '<span><img src=' + _VirtualPath.Static + 'main/image/room/icon/vip.png alt="VIP"></span>';
                        }
                        if (data.RoomGuardian && data.RoomGuardian_Mode == "MONTH") {

                            userItem += '<span><img src=' + _VirtualPath.Static + 'main/image/room/icon/Ico-guard-month.png alt="月守护"></span>';
                        }
                        if (data.RoomGuardian && data.RoomGuardian_Mode == "YEAR") {

                            userItem += '<span><img src=' + _VirtualPath.Static + 'main/image/room/icon/Ico-guard-year.png alt="年守护"></span>';
                        }
                        if (data.RoomAdmin) {
                            userItem += '<span><img src=' + _VirtualPath.Static + 'main/image/room/icon/Ico-admin.png alt="管理"></span>';
                        }
                        userItem += '<span class="name">' + data.NickName + '</span>';
                        userItem += '</li>';

                        $("#J_AdminList").append(userItem);
                        // $("#J_UserList li[data-uid=123]").before('<li id="li4">4</li>'); //加在元素前面
                        // $("#J_UserList li[data-uid=123]").after('<li id="li5">5</li>'); //加在元素后面

                        $("#J_AdminList li[data-uid=" + data.User_ID + "]").data("key", data);
                        $("#J_AdminList li[data-uid=" + data.User_ID + "]").off('click');
                        $("#J_AdminList li[data-uid=" + data.User_ID + "]").on('click', function (e) {
                            //  if (!$.CommonMain.LoginCheck()) return ;
                            var _left = $(this).offset().left+8;
                            var _top = $(this).offset().top + $(this).height() + 8;
                            $("#J_UserCardPop").data('userinfo', data);
                            $("#J_UserCardPop").css({
                                left: _left,
                                top: _top,
                                zIndex:1000
                            }).fadeIn();
                            $("#J_UserCardPop .MCard-Arrow").css({
                                left:"12px"
                            })
                            _ThisPage.Page.CommonUitls.CreateUserInfoMiniCard(data);
                        });
                    },
                }
            },
            /**
             * 用户升级提示
             */
            UserLevelUpgrade:{
                Data:{
                    Arr:[], //升级提示列队
                    Interval:0, //时间间隔
                    IsStart:false //是否已开始显示
                },
                Test:{
                    Init:function(){
                        var data = {
                            RoomUserInfo:{
                                NickName:"用户昵称",
                                Level:3
                            }
                        };
                        for(var i=0;i<2;i++){
                            _ThisPage.Page.UserLevelUpgrade.AddItem(data);
                        }
                    }
                },
                AddItem:function (data) {
                    _ThisPage.Page.UserLevelUpgrade.Data.Arr.push(data);
                    if(_ThisPage.Page.UserLevelUpgrade.Data.IsStart) return;
                    _ThisPage.Page.UserLevelUpgrade.Data.IsStart = true;
                    _ThisPage.Page.UserLevelUpgrade._Show(_ThisPage.Page.UserLevelUpgrade.Data.Arr[0]);
                    _ThisPage.Page.UserLevelUpgrade.Data.Arr.splice(0,1);
                    _ThisPage.Page.UserLevelUpgrade.Data.Interval = setInterval(function () {
                        if(_ThisPage.Page.UserLevelUpgrade.Data.Arr.length<=0){
                            clearInterval(_ThisPage.Page.UserLevelUpgrade.Data.Interval);
                            _ThisPage.Page.UserLevelUpgrade.Data.IsStart = false;
                            $("#J_UserLevelTips").html('');
                            return ;
                        }
                        _ThisPage.Page.UserLevelUpgrade._Show(_ThisPage.Page.UserLevelUpgrade.Data.Arr[0]);
                        _ThisPage.Page.UserLevelUpgrade.Data.Arr.splice(0,1);
                    }, 5000);
                },
                _Show:function (data) {
                    var html = '<ul class="WebChatListInfo" id="J_UserLevelTipsHtml" style="background: url('+_VirtualPath.Static+'main/image/room/bg-sidebg.png) repeat;width:534px;padding:3px;line-height: 20px;height: 20px;"><li class="enter"><span class="welcome">恭喜</span> <span class="username" data-uid="63">'+
                        data.RoomUserInfo.NickName+'</span> 升级到 <em class="userlev"><img src="'+
                        _VirtualPath.Static+'main/image/common/level/user/'+
                        data.RoomUserInfo.Level+'.png" alt="'+
                        data.RoomUserInfo.Level+'"></em></li></ul>';
                    $("#J_UserLevelTips").html(html);
                }
            },
            /**
             * 跑道
             */
            Runway_1:{
                Data:{
                    // CheckIndex:0, //定时检查索引
                    // CheckInterval:0, //定时检查数据
                    TimeIndex:0, //定时索引
                    TimeInterval:0, //setTimeout
                    IsShow:false,//是否正在运行中
                    Arr:[], //队列数据
                    TempTime:0, //开通守护面板显示时间
                },
                Init:function(){
                },
                AddRunway:function (data) {
                    this.Data.Arr.push(data);
                    if(this.Data.IsShow) return;
                    this._RunwayRuning();
                },
                _RunwayRuning:function () {
                    this.Data.IsShow = true;
                    _ThisPage.Page.Runway.Data.TimeIndex = 0;
                    var data = this.Data.Arr[0];
                    var _Item = '';
                    var html = "";
                    var TargetUser = (data.Data.RoomUserInfo_Gift) ? data.Data.RoomUserInfo_Gift : data.Data.RoomAnchorInfo;
                    if(data.Type == "Guardian"){
                        //开通守护特效
                        _Item +='<div class="main-chat-broadcast" id="J_OpenAnchorGuardPanel">'+
                            '<div class="chat-broadcast-guard">'+
                            '<p class="cbg-cove">'+
                            '<img src="'+_ThisPage.Page.CommonUitls.GetUserHand(data.Data.RoomUserInfo.User_ID,"80.80")+'" alt="" class="cbg-cover-thumb">'+
                            '</p>'+
                            '<p class="cbg-name">'+data.Data.RoomUserInfo.NickName+'</p>'+
                            '<p class="cbg-desc">为 '+data.Data.RoomAnchorInfo.NickName+' 开通了守护!</p>'+
                            '</div>'+
                            '</div>';
                        $("#J_AnchorGuard").append(_Item);
                        clearTimeout(_ThisPage.Page.Runway_1.Data.TempTime);
                        _ThisPage.Page.Runway_1.Data.TempTime = setTimeout(function(){
                            $("#J_OpenAnchorGuardPanel").remove();
                        }, 5000);
                        //守护跑道
                        html += '<a href ='+_VirtualPath.Main+"room/"+data.Data.RoomAnchorInfo.RoomID+' class="orange">'+
                                '恭喜 '+
                                '<img src="'+_ThisPage.Page.CommonUitls.GetUserHand(data.Data.RoomUserInfo.User_ID)+'" class="thumb">'+
                                '<span class="zsuser">'+data.Data.RoomUserInfo.NickName+'</span>'+
                                '成为 <span class="zsuser">'+data.Data.RoomAnchorInfo.NickName+'</span> '+
                                '的守护神！'+"</a>";
                    }else if(data.Type == "Gift"){
                        //礼物跑道
                        html += '<a href ='+_VirtualPath.Main+"room/"+data.Data.RoomUserInfo.RoomID+' class="orange">';
                        html += '<img src="'+_ThisPage.Page.CommonUitls.GetUserHand(data.Data.RoomUserInfo.User_ID)+'" class="thumb">';
                        html += '<span class="zsuser">'+data.Data.RoomUserInfo.NickName+'</span>';
                        html += '送给<span class="zsuser">' + TargetUser.NickName + '</span>';
                        html += '<img src="'+_VirtualPath.Static+'/main/image/room/gift/'+data.Data.GiftInfo.id+'.png"  alt="'+data.Data.GiftInfo.Name+'" />';
                        html += '<span class="num">x '+data.Data.GiftNum+"</span>";
                        html += '</a>';
                    }
                    html = '<div class="RunWayStyle">'+html+'</div>';
                    $("#J_RunWay").html(html);
                    _ThisPage.Page.Runway.Data.Arr.splice(0,1); //删除这条数据

                    //显示下一条
                    clearInterval(this.Data.TimeInterval);
                    this.Data.TimeInterval = setInterval(function () {
                        if(_ThisPage.Page.Runway.Data.Arr.length>0){
                            _ThisPage.Page.Runway._RunwayRuning();
                        }else if( _ThisPage.Page.Runway.Data.TimeIndex >= 5 ){
                            clearInterval(_ThisPage.Page.Runway.Data.TimeInterval);
                            _ThisPage.Page.Runway.Data.IsShow = false;
                            $("#J_RunWay").empty();
                            $("#J_AnchorGuard .main-chat-broadcast").remove();
                        }
                        _ThisPage.Page.Runway.Data.TimeIndex++;
                    }, 1000*3); //显示时间 10 秒
                }
            },
            Runway:{
                Data:{
                    TempInterval:0, //检查时间间隔
                    TempTimeOut:0,
                    TempIndex:0,
                    Arr:[], //队列数据
                    TempTime:0, //开通守护面板显示时间
                    ItemArr:[], //跑道ITEM
                    IsRuning:false
                },
                Test:{
                    Init:function(){
                        for(var i=0;i<2;i++){
                            var data = {
                                Type:"Gift",
                                Data:{
                                    RoomUserInfo_Gift:{
                                        RoomID:4605,
                                        User_ID:123,
                                        NickName:"昵称接收",
                                    },
                                    RoomUserInfo:{
                                        RoomID:4605,
                                        User_ID:123,
                                        NickName:"昵称送出",
                                    },
                                    GiftInfo:{
                                        id:60,
                                        Name:"黄瓜"
                                    },
                                    RoomAnchorInfo:{
                                        RoomID:4605
                                    },
                                    GiftNum:123
                                }
                            };
                            _ThisPage.Page.Runway.AddRunway(data);
                        }
                    }
                },
                Init:function(){
                    // this.Test.Init();
                    clearInterval(this.Data.TempIntreval);
                    this.Data.TempIntreval = setInterval(this._RunwayRuning,100);
                },
                AddRunway:function (data) {
                    this.Data.Arr.push(data);
                },
                _RunwayRuning:function () {
                    if(_ThisPage.Page.Runway.Data.Arr.length <= 0) return;
                    var stepNum = 30;
                    var totalWidth = $("#J_RunWay").width();
                    var parentObj = (_ThisPage.Page.Runway.Data.ItemArr.length > 0) ? _ThisPage.Page.Runway.Data.ItemArr[_ThisPage.Page.Runway.Data.ItemArr.length-1] : null;
                    if(parentObj != null && $("#"+parentObj.id).length > 0 && getNum($("#"+parentObj.id).css("left"))+parentObj.itemWidth+stepNum > totalWidth ){
                        return ;
                    }
                    var data = _ThisPage.Page.Runway.Data.Arr[0];
                    _ThisPage.Page.Runway.Data.Arr.splice(0, 1);

                    _ThisPage.Page.Runway.Data.TempIndex++;
                    var id = "runway"+_ThisPage.Page.Runway.Data.TempIndex;
                    var html = "";
                    var TargetUser = (data.Data.RoomUserInfo_Gift) ? data.Data.RoomUserInfo_Gift : data.Data.RoomAnchorInfo;
                    if(data.Type == "Guardian"){
                        //在同房间显示//开通守护特效
                        if($.CommonMainRoom.RoomInfo.RoomID == TargetUser.RoomID){
                            var _Item ='<div class="main-chat-broadcast" id="J_OpenAnchorGuardPanel"><div class="chat-broadcast-guard">'+
                            '<p class="cbg-cove">'+
                            '<img src="'+_ThisPage.Page.CommonUitls.GetUserHand(data.Data.RoomUserInfo.User_ID,"80.80")+'" alt="" class="cbg-cover-thumb">'+
                            '</p>'+
                            '<p class="cbg-name">'+data.Data.RoomUserInfo.NickName+'</p>'+
                            '<p class="cbg-desc">为 '+data.Data.RoomAnchorInfo.NickName+' 开通了守护!</p>'+
                            '</div>'+
                            '</div>';
                            $("#J_AnchorGuard").append(_Item);

                            clearTimeout(_ThisPage.Page.Runway.Data.TempTime);
                            _ThisPage.Page.Runway.Data.TempTime = setTimeout(function(){
                                $("#J_OpenAnchorGuardPanel").remove();
                            }, 5000);
                        }
                        //守护跑道
                        html += '<a href ='+_VirtualPath.Main+"room/"+data.Data.RoomAnchorInfo.RoomID+' class="orange">'+
                            '恭喜 '+
                            '<img src="'+_ThisPage.Page.CommonUitls.GetUserHand(data.Data.RoomUserInfo.User_ID)+'" class="thumb">'+
                            '<span class="zsuser">'+data.Data.RoomUserInfo.NickName+'</span>'+
                            '成为 <span class="zsuser">'+data.Data.RoomAnchorInfo.NickName+'</span> '+
                            '的守护神！'+"</a>";
                    }else if(data.Type == "Gift"){
                        //礼物跑道
                        html += '<a href ='+_VirtualPath.Main+"room/"+data.Data.RoomUserInfo.RoomID+' class="orange">';
                        html += '<img src="'+_ThisPage.Page.CommonUitls.GetUserHand(data.Data.RoomUserInfo.User_ID)+'" class="thumb" style="border-radius: 50%">';
                        html += '<span class="zsuser">'+data.Data.RoomUserInfo.NickName+'</span>';
                        html += '送给<span class="jsuser">' + TargetUser.NickName + '</span>';
                        html += '<img src="'+_VirtualPath.Static+'/main/image/room/gift/'+data.Data.GiftInfo.id+'.png"  alt="'+data.Data.GiftInfo.Name+'" />';
                        html += '<span class="num">x '+data.Data.GiftNum+"</span>";
                        html += '</a>';
                    }
                    html = '<li id="'+id+'">'+html+'</li>';
                    $("#J_RunWay").append(html);

                    //动画控制
                    var itemWidth = $("#"+id).width();
                    $("#"+id).css({"position":"absolute"}).css({"left":totalWidth});//初始化位置
                    _ThisPage.Page.Runway.Data.ItemArr.push( {id:id, itemWidth:itemWidth} );
                    Log.Out("===================>id", {id:id, itemWidth:itemWidth, totalWidth:totalWidth});
                    var tempInterval_1 = setInterval(function (id) {
                        var currLeft = getNum($("#"+id).css("left"));
                        if(parentObj != null && $("#"+parentObj.id).length > 0){
                            if(getNum($("#"+parentObj.id).css("left"))+$("#"+parentObj.id).width()+stepNum*2 >= currLeft){
                                return ;
                            }
                        }
                        // if( currLeft <= 4 ){
                        //     clearInterval(tempInterval_1);
                        //     var tempTimeout_1= setTimeout(function(itemObj){
                        //         $("#"+itemObj.id).animate({"opacity":0}, 500, "linear", function(){
                        //             $("#"+itemObj.id).remove();
                        //             _ThisPage.Page.Horn.Data.ItemArr[0] = null;
                        //             _ThisPage.Page.Horn.Data.ItemArr.splice(0, 1);
                        //         });
                        //     }, 1200, {id:id, itemWidth:itemWidth} );
                        // }
                        if(currLeft+itemWidth <= 0){
                            if(_ThisPage.Page.Runway.Data.ItemArr.length > 1){
                                $("#"+id).remove();
                                _ThisPage.Page.Runway.Data.ItemArr[0] = null;
                                _ThisPage.Page.Runway.Data.ItemArr.splice(0,1);
                            }else{
                                currLeft = totalWidth;
                            }
                        }
                        $("#"+id).css({"left": currLeft-2 });

                    }, 30, id);

                    function getNum(px){
                        if(px == null) return 0;
                        return Number(px.replace("px",""));
                    }
                    return id;







                }
            },
            /**
             * 星星
             */
            PomeloUtil:{
                Data:{
                    Num:0,//星星数量
                    TempInterval:0,//时间间隔5分钟 获取下星星
                    MaxTime:60*5,//5分钟(秒)
                    CurrTime:0,//当前时间
                    isFull:false//当前是否累积满星星了
                },
                Init:function (data) {
                    //艺人的星星
                    // $("#J_AnchorPomeloNum").text(data.Pomelo);
                    $(".Beannum").off("webkitAnimationEnd webkitTransitionEnd otransitionend transitionend animationend","span");
                    $(".Beannum").on("webkitAnimationEnd webkitTransitionEnd otransitionend transitionend animationend","span",function(e){
                        $(this).remove();
                    });
                    $("#J_ShowAddSelfExp").off("webkitAnimationEnd webkitTransitionEnd otransitionend transitionend animationend","span");
                    $("#J_ShowAddSelfExp").on("webkitAnimationEnd webkitTransitionEnd otransitionend transitionend animationend","span",function(e){
                        $(this).remove();
                    });
                    $("#J_youziBtn").off("click");
                    $("#J_youziBtn").on("click",function (e) {
                        if (!$.CommonMain.LoginCheck()) return ;
                        if( _StateData.User_ID == _PageData.RoomID){
                            $.CommonMain.Modal_Tip('艺人不能送给自己星星！', {Timeout: 1500});
                            Log.Out("艺人不能送给自己星星！");
                            return ;
                        }
                        if (_ThisPage.Page.PomeloUtil.Data.Num <=0) return;
                        _ThisPage.Page.PomeloUtil.Data.Num--;
                        $("#J_youziNum").text(_ThisPage.Page.PomeloUtil.Data.Num);
                        // _SocketEmit.PomeloPresent(1);//每次扔一个
                        $.CommonMainRoom.SocketEmit.PomeloPresent(1);
                        _ThisPage.Page.PomeloUtil.Data.isFull = false;

                        $(".Beannum").append('<span class="AnchorPomeloNumTips AnchorPomeloNumStyle">+1</span>');//艺人提示动画
                        $("#J_ShowAddSelfExp").append('<span class="AddUserExpPomelo AddUserExpPomeloStyle">+25</span>');//增加自己经验值动画


                        // 添加礼物到历史记录列表
                        // GiftEffectFactory.GiftHistoryList( $("#J_GiftHistoryListDiv"), $("#J_GiftHistoryList"), data);
                        // $("#J_GiftHistoryListDiv").perfectScrollbar();
                    });
                    $("#J_youziBtn").off("mouseover");
                    $("#J_youziBtn").on("mouseover",function (e) {
                        if(!_StateData.IsLogin) return;
                        if(_ThisPage.Page.PomeloUtil.Data.isFull) return;
                        $("#J_PomeloTime").show();
                    });
                    $("#J_youziBtn").off("mouseout");
                    $("#J_youziBtn").on("mouseout",function (e) {
                        if(!_StateData.IsLogin) return;
                        $("#J_PomeloTime").hide();
                    });
                    // Log.Out("初始化星星", data);

                    //自己显示的星星
                    if(_StateData.IsLogin){
                        _ThisPage.Page.PomeloUtil.Data.Num = data.Pomelo;
                        $("#J_youziNum").text(_ThisPage.Page.PomeloUtil.Data.Num);
                        _ThisPage.Page.PomeloUtil.Data.CurrTime = _ThisPage.Page.PomeloUtil.Data.MaxTime;
                        clearInterval(_ThisPage.Page.PomeloUtil.Data.TempInterval);
                        _ThisPage.Page.PomeloUtil.Data.TempInterval = setInterval(function () {
                            _ThisPage.Page.PomeloUtil.Data.CurrTime--;
                            $("#J_PomeloTimeNum").text(_ThisPage.Page.PomeloUtil.Data.CurrTime);
                            if(_ThisPage.Page.PomeloUtil.Data.CurrTime <= 0){
                                $.CommonMainRoom.SocketEmit.PomeloGet();//请求领取星星
                                _ThisPage.Page.PomeloUtil.Data.CurrTime = _ThisPage.Page.PomeloUtil.Data.MaxTime;
                            }
                        }, 1000);//5分钟
                    }else{
                        //游客的星星
                        $("#J_youziNum").text("10");//游客默认初始化 10 星星
                    }
                },
                //更新自己的星星数量
                UpdateSelfPomeloNum:function (data) {
                    _ThisPage.Page.PomeloUtil.Data.Num = data.Pomelo;
                    $("#J_youziNum").text(_ThisPage.Page.PomeloUtil.Data.Num);
                    // $("#J_Anchor_Attention").text(data.Anchor_Fans);
                    // 添加礼物到历史记录列表
                    // GiftEffectFactory.GiftHistoryList( $("#J_GiftHistoryListDiv"), $("#J_GiftHistoryList"), data);
                    // $("#J_GiftHistoryListDiv").perfectScrollbar();
                },
                //显示历史记录 谁赠送的星星
                ShowPomeloHistoryList:function (data) {
                    _ThisPage.Page.PomeloUtil.ShowPomeloAnimation(data.Num);

                    var giftData = {
                        CreateDate:new Date(),
                        Gift_ID:0, //暂定 星星ID 为 0
                        GiftName:"星星",
                        RoomAnchor:true,
                        UserInfo:{
                            Level:data.RoomUserInfo.Level,
                            NickName:data.RoomUserInfo.NickName
                        },
                        UserInfo_Gift:{
                            RoomAnchor:true,
                            NickName:data.RoomAnchorInfo.NickName,
                            Level:data.RoomAnchorInfo.Level
                            // NickName:$.CommonMainRoom.RoomAnchorInfo.NickName,
                            // Level:$.CommonMainRoom.RoomAnchorInfo.Level
                        },
                        Num:1
                    };
                    GiftEffectFactory.GiftHistoryList( $("#J_GiftHistoryListDiv"), $("#J_GiftHistoryList"), giftData);//显示礼物历史记录
                },
                //增加星星动画
                ShowPomeloAnimation:function (Num) {
                    $(".Beannum").append('<span class="AnchorPomeloNumTips AnchorPomeloNumStyle">+'+Num+'</span>');
                }
            },
            /**
             * 排行榜
             */
            Ranking:{
                Data:{
                    currType:null //当前 显示的 贡献榜 类型
                },
                Init:function () {
                    //初始显示周榜
                    _ThisPage.Page.Ranking.LoadData(1);
                    //按钮事件
                    $("#J_RankingTabBtn").off('click');
                    $("#J_RankingTabBtn").on('click', 'a', function (event) {
                        var index = $(this).index();
                        $(this).addClass('active').siblings().removeClass('active');
                        _ThisPage.Page.Ranking.LoadData(index);
                    });
                    $(".RankList").perfectScrollbar();
                },
                LoadData:function (tabBtnIndex) {
                    $("#J_RankingTop3").empty();
                    $("#J_RankingOther").empty();
                    var random = Math.floor(new Date().getTime()/30000)*30000;//30秒
                    var typeArr = ["Live","Week","Year"];
                    _ThisPage.Page.Ranking.Data.currType = typeArr[tabBtnIndex];
                    $.getJSON("/ajax/user.user-contribution.list?r="+random, {
                        TopN:20,
                        User_ID:_PageData.RoomID,
                        OrderBy:typeArr[tabBtnIndex]
                        // case "Live"://本场排行
                        // case "Day"://天排行
                        // case "Week"://周排行
                        // case "Month"://月排行
                        // case "Year"://总排行
                    }, function (json) {
                        if (json.flag !== 0) {
                            _ThisPage.Page.CommonUitls.Tip("Error "+json.msg+" "+json.flag);
                            return;
                        }
                        _ThisPage.Page.Ranking.ShowRanking(json.data);
                    });
                },
                ShowRanking:function (data) {
                    $("#J_RankingTop3").empty();
                    $("#J_RankingOther").empty();
                    _.forEach(data, function(value, key) {
                        var Coin = value["Coin_"+_ThisPage.Page.Ranking.Data.currType];
                        if(key<3){
                            var item_1 = '<li class="top'+(key+1)+'">';
                            item_1 += '<p class="userpic">';
                            item_1 += '<a href="javascript:;"><img src="'+_ThisPage.Page.CommonUitls.GetUserHand(data[key].User_ID)+'" alt="'+value.NickName+'" class="thumb"></a>';
                            item_1 += '<span class="TopRank'+(key+1)+'"></span>';
                            item_1 += '</p>';
                            item_1 += '<p class="username">'+value.NickName+'</p>';
                            item_1 += '<p><span class="coin">'+Coin+'</span></p>';
                            item_1 += '</li>';
                        }else{
                            var item_2 = '<li>';
                            item_2 += '<b class="num">'+(key+1)+'、</b><span class="username">'+value.NickName+'</span>';
                            item_2 += '<span class="coin">'+Coin+'</span>';
                            item_2 += '</li>';
                        }
                        $("#J_RankingTop3").append(item_1);
                        $("#J_RankingOther").append(item_2);
                    });
                }
            },
            /**
             * 分享
             */
            Share:{
                Data:{
                    IsEnter:false
                },
                Init:function () {
                    $("title").text( $.CommonMainRoom.RoomAnchorInfo.NickName + "的直播间|全民秀网|美女视频|互动娱乐平台");
                    window._bd_share_config.common.bdDesc = '看直播，上#全民秀#！【'+
                        $.CommonMainRoom.RoomAnchorInfo.NickName+
                        '】（房间号：'+$.CommonMainRoom.RoomAnchorInfo.RoomID+
                        '）已入驻全民秀网#视频直播秀#，众多美女都在这里，大家都来看看啊！';
                    window._bd_share_config.common.bdText = window._bd_share_config.common.bdDesc;
                    window._bd_share_config.common.bdPic = _ThisPage.Page.CommonUitls.GetAvatarHand($.CommonMainRoom.RoomAnchorInfo.RoomID,"160.126");
                    window._bd_share_config.common.bdUrl = "http://www.quanminxiu.tv/room/"+$.CommonMainRoom.RoomAnchorInfo.RoomID;
                    with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?cdnversion='+~(-new Date()/36e5)];
                    _ThisPage.Page.Share.InitBtnEvent();
                },
                InitBtnEvent:function () {
                    $("#J_ShareLinkBtn,#J_SharePanel").off("mouseenter");
                    $("#J_ShareLinkBtn,#J_SharePanel").on("mouseenter", function () {
                        _ThisPage.Page.Share.Data.IsEnter = true;
                        _ThisPage.Page.Share.ShowSharePanel();
                    });
                    $("#J_ShareLinkBtn,#J_SharePanel").off("mouseleave");
                    $("#J_ShareLinkBtn,#J_SharePanel").on("mouseleave", function () {
                        _ThisPage.Page.Share.Data.IsEnter = false;
                        setTimeout(_ThisPage.Page.Share.HideSharePanel, 200);
                    });
                },
                ShowSharePanel:function () {
                    if($("#J_SharePanel").is(':hidden')){
                        $("#J_SharePanel").show();
                        $("#J_SharePanel").css({opacity:0, top:50});
                        $("#J_SharePanel").animate({ opacity:1, top:0 }, 300, "swing");
                    }
                },
                HideSharePanel:function () {
                    if(!_ThisPage.Page.Share.Data.IsEnter && !$("#J_SharePanel").is(':hidden')){
                        $("#J_SharePanel").css({opacity:1});
                        $("#J_SharePanel").animate({ opacity:0, top:-50 }, 300, "swing", function () {
                            $("#J_SharePanel").hide();
                        });
                    }
                }
            },
            /**
             * 飞屏，喇叭
             */
            FlyScreen:{
                Data:{
                    FlyScreenMode:"ROOM",//_PageData.Commodity.Horn
                    HornMode:"SERVER"
                },
                //初始化
                Init:function () {
                    //飞屏按钮
                    $("#J_FlyScreenBtn").off("click");
                    $("#J_FlyScreenBtn").on("click",function () {
                        if (!$('#J_FlyScreenInputPanel').is(':hidden')) return;
                        $("#J_FlyScreenBtn").css({opacity:0.5});

                        _ThisPage.Page.FlyScreen.ShowPublishPanel();
                        $("#J_FlyScreenInputText").attr("placeholder", "请输入飞屏文字...");
                        $("#J_FlyScreenPrice").text("2000");

                        var ObjData = _.filter($.CommonMainRoom.UserPackage, {Item_ID:"ROOM"});
                        if(ObjData[0].Num > 0){
                            $("#J_FreeFlyHornNumDiv").show();
                            $("#J_FreeFlyHornNum").text(ObjData[0].Num);
                        }else{
                            $("#J_FreeFlyHornNumDiv").hide();
                        }
                    });
                    //关闭按钮
                    $("#J_FlyScreenInputPanelCloseBtn").off("click");
                    $("#J_FlyScreenInputPanelCloseBtn").on("click",function () {
                        _ThisPage.Page.FlyScreen.HidePublishPanel();
                        $("#J_InputTextWord").focus();
                    });
                    //文字输入框
                    $("#J_FlyScreenInputText").off("keyup");
                    $("#J_FlyScreenInputText").on("keyup", function () {
                        var count = 30-$("#J_FlyScreenInputText").val().length;
                        $("#J_FlyScreenTextCount").text(count);
                    });
                    //发布按钮
                    $("#J_FlyScreenPublishBtn").off("click");
                    $("#J_FlyScreenPublishBtn").on("click", function () {
                        if (!$.CommonMain.LoginCheck()) return ;

                        var text = $("#J_FlyScreenInputText").val();
                        if(text == null) return ;
                        if(text.length <= 0) return;

                        if( $("#J_FlyScreenInputText").attr("placeholder").indexOf("飞屏") != -1 ){
                            // _SocketEmit.FlyScreen(text); // 飞屏
                            $.CommonMainRoom.SocketEmit.Horn(_ThisPage.Page.FlyScreen.Data.FlyScreenMode, text);
                        }else{
                            // _SocketEmit.Horn(text); // 喇叭
                            $.CommonMainRoom.SocketEmit.Horn(_ThisPage.Page.FlyScreen.Data.HornMode, text);
                        }
                        $("#J_FlyScreenInputText").val("");
                        $("#J_InputTextWord").focus();
                        _ThisPage.Page.FlyScreen.HidePublishPanel();
                    });
                },
                //显示发布面板
                ShowPublishPanel:function () {
                    $("#J_FlyScreenInputPanel").show();
                    $("#J_FlyScreenInputText").val("").focus();
                    $("#J_FlyScreenTextCount").text(30);
                    $("#J_FlyScreenInputPanel").addClass("flipInX animated");
                    $('#J_FlyScreenInputPanel').off('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend');
                    $('#J_FlyScreenInputPanel').on('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
                        $("#J_FlyScreenInputPanel").removeClass("flipInX animated");
                    });
                },
                //隐藏发布面板
                HidePublishPanel:function () {
                    $("#J_HornBtn,#J_FlyScreenBtn").css({opacity:1});
                    $("#J_FlyScreenInputPanel").addClass("flipOutX animated");
                    $('#J_FlyScreenInputPanel').off('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend');
                    $('#J_FlyScreenInputPanel').on('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
                        $("#J_FlyScreenInputPanel").removeClass("flipOutX animated");
                        $("#J_FlyScreenInputPanel").hide();
                    });
                },
                //显示飞屏效果动画
                ShowEffect:function (data) {
                    var userInfo = {
                        Level:data.RoomUserInfo.Level,
                        NickName:data.RoomUserInfo.NickName,
                        text:data.HornMessage
                    };
                    onJsToAs({type: "flyscreen_addData", data:userInfo });
                }
            },
            /**
             * 喇叭
             */
            Horn:{
                Data:{
                    TempInterval:0,
                    TempTimeOut:0,
                    TempIndex:0,
                    Arr:[],
                    ItemArr:[],
                    IsRuning:false
                },
                Test:{
                    Init:function () {
                        for(var i=0; i<10; i++){
                            var data = {
                                RoomUserInfo:{
                                    Level:12,
                                    NickName:"昵称"
                                },
                                RoomAnchorInfo:{
                                    RoomID:123
                                },
                                HornMessage: i+"_一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十"
                            };
                            _ThisPage.Page.Horn.ShowEffect(data);
                        }
                    }
                },
                Init:function () {
                    //喇叭按钮
                    $("#J_HornBtn").off("click");
                    $("#J_HornBtn").on("click", function () {
                        if (!$('#J_FlyScreenInputPanel').is(':hidden')) return;
                        $(this).css({opacity:0.5});

                        _ThisPage.Page.FlyScreen.ShowPublishPanel();
                        $("#J_FlyScreenInputText").attr("placeholder", "请输入喇叭文字...");
                        $("#J_FlyScreenPrice").text("5000");

                        if($.CommonMainRoom.UserPackage && $.CommonMainRoom.UserPackage.length > 0){
                            var ObjData = _.filter($.CommonMainRoom.UserPackage, {Item_ID:"SERVER"});
                            if(ObjData.length > 0 && ObjData[0].Num > 0){
                                $("#J_FreeFlyHornNumDiv").show();
                                $("#J_FreeFlyHornNum").text(ObjData[0].Num);
                            }else{
                                $("#J_FreeFlyHornNumDiv").hide();
                            }
                        }
                    });
                    clearInterval(_ThisPage.Page.Horn.Data.TempInterval);
                    _ThisPage.Page.Horn.Data.TempInterval = setInterval(function(){
                        // _ThisPage.Page.Horn._ShowEffect();
                        var item = _ThisPage.Page.Horn._EffectItemClass();

                    }, 1000);

                    //测试
                    // _ThisPage.Page.Horn.Test.Init();
                },
                ShowEffect:function (data) {
                    _ThisPage.Page.Horn.Data.Arr.push(data);
                },
                _EffectItemClass:function(){
                    if(_ThisPage.Page.Horn.Data.Arr.length <= 0) return;
                    var stepNum = 30;
                    var totalWidth = $("#J_HornList").width();
                    var parentObj;
                    if(_ThisPage.Page.Horn.Data.ItemArr.length > 0){
                        parentObj = _ThisPage.Page.Horn.Data.ItemArr[_ThisPage.Page.Horn.Data.ItemArr.length-1];
                    }
                    if(parentObj != null && $("#"+parentObj.id).length > 0 && getNum($("#"+parentObj.id).css("left"))+parentObj.itemWidth+stepNum > totalWidth ){
                        return ;
                    }

                    var data = _ThisPage.Page.Horn.Data.Arr[0];
                    _ThisPage.Page.Horn.Data.Arr.splice(0, 1);
                    _ThisPage.Page.Horn.Data.TempIndex++;
                    var id = "horn"+_ThisPage.Page.Horn.Data.TempIndex;
                    var html = '<li id="'+id+'"><img src="'+_VirtualPath.Static+'main/image/common/level/user/' +
                        data.RoomUserInfo.Level +
                        '.png" alt="" class="mr4"><a href="/room/' +
                        data.RoomAnchorInfo.RoomID +
                        '" class="alink" target="_blank"><span class="name">' +
                        data.RoomUserInfo.NickName +
                        '</span> 说：' +
                        data.HornMessage +
                        '</a></li>';
                    $("#J_HornList").append(html);
                    //动画控制
                    var itemWidth = $("#"+id).width();
                    _ThisPage.Page.Horn.Data.ItemArr.push( {id:id, itemWidth:itemWidth} );

                    // $("#"+id).css({"margin-left":totalWidth});
                    // $("#"+id).animate({"margin-left":0}, 10000, "linear");

                    $("#"+id).css({"position":"absolute"}).css({"left":totalWidth});
                    var tempInterval_1 = setInterval(function () {
                        var currLeft = getNum($("#"+id).css("left"));
                        if(parentObj != null && $("#"+parentObj.id).length > 0){
                            if(getNum($("#"+parentObj.id).css("left"))+$("#"+parentObj.id).width()+stepNum >= currLeft){
                                return ;
                            }
                        }
                        if( currLeft <= 4 ){
                            clearInterval(tempInterval_1);
                            var tempTimeout_1= setTimeout(function(itemObj){
                                $("#"+itemObj.id).animate({"opacity":0}, 500, "linear", function(){
                                    $("#"+itemObj.id).remove();
                                    _ThisPage.Page.Horn.Data.ItemArr[0] = null;
                                    _ThisPage.Page.Horn.Data.ItemArr.splice(0, 1);
                                });
                            }, 1200, {id:id, itemWidth:itemWidth} );
                        }
                        $("#"+id).css({"left": currLeft-2 });
                    }, 30);
                    function getNum(px){
                        if(px == null) return 0;
                        return Number(px.replace("px",""));
                    }
                    return id;
                },
                _ShowEffect:function () {
                    if( _ThisPage.Page.Horn.Data.Arr.length <= 0 ) return;
                    if( _ThisPage.Page.Horn.Data.IsRuning ) return;
                    _ThisPage.Page.Horn.Data.IsRuning = true;

                    var data = _ThisPage.Page.Horn.Data.Arr[0];
                    _ThisPage.Page.Horn.Data.Arr.splice(0, 1);

                    var html = '<li><img src="'+_VirtualPath.Static+'main/image/common/level/user/' +
                        data.RoomUserInfo.Level +
                        '.png" alt="" class="mr4"><a href="/room/' +
                        data.RoomAnchorInfo.RoomID +
                        '" class="alink"><span class="name">' +
                        data.RoomUserInfo.NickName +
                        '</span>说：' +
                        data.HornMessage +
                        '</a></li>';
                    $("#J_HornList").append(html);
                    var totalWidth = $("#J_HornList").width();
                    var itemWidth = $("#J_HornList li").width();
                    var centerX = Math.floor((totalWidth-itemWidth)*0.5);
                    // $("#J_HornList li").css({"margin-left":totalWidth, "background-color":0xFF0000});
                    $("#J_HornList li").css({"margin-left":totalWidth});
                    $("#J_HornList li").animate({"margin-left":0}, 10000, "linear");
                    // clearTimeout(_ThisPage.Page.Horn.Data.TempTimeOut);
                    _ThisPage.Page.Horn.Data.TempTimeOut = setTimeout(function(itemWidth){
                        $("#J_HornList li").animate({"opacity":0}, 1000, "linear", function(){
                            $("#J_HornList").empty();
                            _ThisPage.Page.Horn.Data.IsRuning = false;
                        });
                    }, 13000, itemWidth);
                }
            },
            /**
             * 暴奖
             */
            PondBroadcast:function (data) {
                if(!(data && data.Burst)) return;
                var html = "";
                for(var i=0;i<data.BurstList.length;i++){
                    var o = data.BurstList[i];
                    _ThisPage.Page.Chat.SysText('<span class="ChatSysTips">恭喜 '+_ThisPage.Page.Chat.CommonUtils.getUserName(o.UserInfo)+' 意外获得 <font color="#F90">'+o.Amt+'</font>'+' 金币！</span>');
                }
                // $("#J_Chatlistinfo").append(html);
                // _ThisPage.Page.Chat.ChatScrollToBottom();
            },
            /**
             * 房间 机器人
             */
            RobotManage:{
                Data:{
                    MaxCount:0,//艺人带入最多机器人数量（根据艺人等级来决定此数量）
                    ShowStatus:false,//显示状态 true 艺人在开播 加减机器人 false未开播 显示真实人数
                    DueRobotCount:0,//应有机器人数量
                    DueRobotCountBak:-1,//应有机器人数量备份
                    CurrRobotCount:0,//当前机器人数
                    RobotIntervalTime:3000,//多少秒 进 出 一个机器人
                    Timer:0,//触发 时间间隔
                    NickNameArr: [] //机器人昵称列表
                },
                //初始化
                Init:function(){
                    var maxCount = Math.ceil($.CommonMainRoom.RoomAnchorInfo.Level / 5 + 1) * 100;
                    this.SetInit(maxCount,$.CommonMainRoom.RoomInfo.Live);
                },
                //加载昵称列表
                LoadNicknameFile:function(filePath){
                    $.get(filePath,{},function(data) {
                        _ThisPage.Page.RobotManage.Data.NickNameArr = data.split("\n");
                        _ThisPage.Page.RobotManage.Data.NickNameArr.sort(function(){
                            return 0.5 - Math.random();
                        });
                    },"text");
                },
                //设置初始数据
                SetInit:function (maxCount, showStatus) {
                    // if(_ThisPage.Page.RobotManage.Data.MaxCount>0) return ;//初始化一次
                    _ThisPage.Page.RobotManage.Data.MaxCount = maxCount;
                    _ThisPage.Page.RobotManage.Data.DueRobotCount = 0;
                    for(var i=0; i<_ThisPage.Page.UserList.Data.ListArr.length; i++){
                        var user = _ThisPage.Page.UserList.Data.ListArr[i];
                        if(!user.IsRobot){
                            _ThisPage.Page.RobotManage.AddRobotCount(user, true);
                        }
                    }

                    if(showStatus){
                        var TotalCount = _ThisPage.Page.RobotManage.Data.DueRobotCount-100;
                        TotalCount = (TotalCount>50) ? 50+Math.random()*100 : TotalCount;
                        for(var ii=0; ii<TotalCount; ii++){
                            _ThisPage.Page.UserList.AddUserItem(_ThisPage.Page.RobotManage._GetUserItemInfo(), true);
                        }
                        $("#J_UserTotal").text(_ThisPage.Page.RobotManage.Data.DueRobotCount-Math.floor(Math.random()*100) );//更新用户列表 数量
                    }else{
                        $("#J_RobotList").empty();
                    }
                },
                //增加机器人数量
                AddRobotCount:function (user, isAdd) {
                    if(user.RoomAnchor){
                        if(isAdd){
                            _ThisPage.Page.RobotManage.Data.DueRobotCount += _ThisPage.Page.RobotManage.Data.MaxCount;
                        }else{
                            _ThisPage.Page.RobotManage.Data.DueRobotCount -= _ThisPage.Page.RobotManage.Data.MaxCount;
                        }
                    }else{
                        if(isAdd){
                            _ThisPage.Page.RobotManage.Data.DueRobotCount += 100;
                        }else{
                            _ThisPage.Page.RobotManage.Data.DueRobotCount -= 100;
                        }
                    }
                },
                //设置【开播/停播】状态
                SetShowStatus:function (showStatus) {
                    _ThisPage.Page.RobotManage.Data.ShowStatus = showStatus;
                    if(_ThisPage.Page.RobotManage.Data.ShowStatus){
                        if(-1 != _ThisPage.Page.RobotManage.Data.DueRobotCountBak){
                            _ThisPage.Page.RobotManage.Data.DueRobotCount = _ThisPage.Page.RobotManage.Data.DueRobotCountBak;
                        }
                    }else if(0 != _ThisPage.Page.RobotManage.Data.DueRobotCount){
                        _ThisPage.Page.RobotManage.Data.DueRobotCountBak = _ThisPage.Page.RobotManage.Data.DueRobotCount;
                        _ThisPage.Page.RobotManage.Data.DueRobotCount = 0;
                    }
                    Log.Out("【设置开播停播状态】", {showStatus:showStatus, DueRobotCount:_ThisPage.Page.RobotManage.Data.DueRobotCount});
                },
                //检查机器人数量
                _CheckRobotCount:function () {
                    var b1 = _ThisPage.Page.RobotManage.Data.CurrRobotCount < _ThisPage.Page.RobotManage.Data.DueRobotCount && _ThisPage.Page.RobotManage.Data.ShowStatus;
                    var b2 = _ThisPage.Page.RobotManage.Data.CurrRobotCount > _ThisPage.Page.RobotManage.Data.DueRobotCount;
                    Log.Out("_CheckRobotCount", [
                        _ThisPage.Page.RobotManage.Data.CurrRobotCount,
                        _ThisPage.Page.RobotManage.Data.DueRobotCount,
                        String(b1),
                        String(b2)]);
                    if(b1){
                        _ThisPage.Page.RobotManage._EnterRoomRobot();
                    }else if(b2){
                        _ThisPage.Page.RobotManage._OutRoomRobot();
                    }
                },
                //进入机器人
                _EnterRoomRobot:function () {
                    Log.Out("进入机器人");
                    var user = _ThisPage.Page.RobotManage._GetUserItemInfo();
                    _ThisPage.Page.UserList.AddUserItem(user, true);
                    _ThisPage.Page.RobotManage.Data.CurrRobotCount++;
                },
                //退出机器人
                _OutRoomRobot:function () {
                    Log.Out("退出机器人");
                    var user = _ThisPage.Page.UserList.getRandomRobot();//随便找个机器人 退出
                    if(user == null) return ;
                    _ThisPage.Page.UserList.removeItem(user, true);
                    _ThisPage.Page.RobotManage.Data.CurrRobotCount--;
                },
                //获取一个临时 机器人信息
                _GetUserItemInfo:function () {
                    // var _NickName = ["浪人", "剑客", "游侠", "英雄", "豪杰", "员外", "侠客", "骑士", "新贵", "狂人", "达人", "学士", "勇士", "首领", "高人", "宗师"];
                    // _NickName = _NickName[parseInt(Math.random() * (_NickName.length - 1))] + parseInt(Math.random() * (99999999 - 10000000) + 10000000);
                    var r = parseInt( Math.random()*_ThisPage.Page.RobotManage.Data.NickNameArr.length );
                    var _NickName = _ThisPage.Page.RobotManage.Data.NickNameArr[r];
                    var user = {};
                    user.User_ID = Math.ceil( Math.random()*99999999+1000000 );
                    user.NickName = _NickName;
                    user.Level = 0;
                    user.RoomAnchor = false;
                    user.IsRobot = true;
                    user.Exp = -_ThisPage.Page.RobotManage.Data.CurrRobotCount;
                    return user;
                }
            },
            /**
             * 任务列表
             */
            TaskList:{
                //初始化
                Init:function(){
                    //展开任务列表
                    var _This= this;
                    var _ThisState = null;
                    $("#J_TaskToK").on("click",function(){
                        if (!$.CommonMain.LoginCheck()) {
                            return;
                        }
                        if($("#J_TaskContainer").length>0){
                            return
                        }
                        _This.LoadTaskList();
                    });
                    
                },
                //加载任务列表
                LoadTaskList:function () {
                    $.ajax({
                        url: '/ajax/user.user-task.list',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            Mode: null, //任务模式 null:所有 DAY WEEK MONTH YEAR(多个,号分隔)
                            Status: null //任务状态 null:所有 0:已领取 1:执行中 2:已完成(多个,号分隔) 3:已过期
                        },
                        success: function (data) {
                            Log.Out("任务列表，结果：", data);
                            if (data.flag !== 0) {
                                _ThisPage.Page.CommonUitls.Tip(data.msg);
                                return;
                            }
                            _ThisPage.Page.TaskList.ShowList(data.data);
                        }
                    });
                },
                //显示列表
                ShowList:function(data){
                    var _Item = '',_Status = '',_StatusClass='',Task_Reward;
                    data.forEach(function(value){
                        if(value.Status == 0){
                            _Status = "已领取";
                            _StatusClass=' finish';
                        }else if(value.Status == 1){
                            _Status = "未完成";
                            _StatusClass=' start';
                        }else if(value.Status == 2){
                            _Status = "马上领取";
                            _StatusClass=' execute';
                        }else if(value.Status == 3){
                            _Status = "已过期";
                            _StatusClass=' fail';
                        }

                        if(typeof value.Task_Reward == "string"){
                            Task_Reward = JSON.parse(value.Task_Reward)[0].Value;
                        }else{
                            Task_Reward = value.Task_Reward[0].Value
                        }

                        //显示列表
                        _Item+='<li class="task-item">'+
                                '<span class="task-name">'+value.Task_Name+'</span>'+
                                '<span class="task-coin">金币*<i>'+Task_Reward+'</i></span>'+
                                '<a href="javascript:;" class="task-state'+_StatusClass+'" data-task-id="'+value.Task_ID+'" data-task-date="'+value.Task_Date+'" data-task-mode="'+value.Task_Mode+'">'+_Status+'</a>'+
                                '</li>';
                    });
                    var _Html = '<div class="xiu-task-container" id="J_TaskContainer">'+
                                '<div class="xiu-task-out">'+
                                '<div class="xiu-task-inner">'+
                                '<div class="xiu-task-header">'+
                                '<h1>赚金币</h1>'+
                                '<p class="task-line">'+
                                '<i class="arrow-bottom"></i>'+
                                '</p>'+
                                '<a href="javascript:;" class="close"></a>'+
                                '</div>'+
                                '<div class="xiu-task-body">'+
                                '<ul class="task-list">'+
                                _Item+
                                '</ul>'+
                                '</div>'+
                                '</div>'+
                                '</div>'+
                                '</div>';
                    $("#J_TaskToK").after(_Html);

                    //点击关闭                        
                    $("#J_TaskContainer").off("click");
                    $("#J_TaskContainer").on('click', 'a.close', function(event) {
                        event.preventDefault();
                        $("#J_TaskContainer").remove();
                    });
                    //点击领取任务奖励
                    $("a.task-state").on('click', function(event) {
                        event.preventDefault();
                        _ThisState = $(this);
                        var Task = {};
                        Task.Task_ID = $(this).data('task-id');
                        Task.Task_Mode = $(this).data('task-mode');
                        Task.Task_Date = $(this).data('task-date');
                        $.ajax({
                            url: '/ajax/user.user-info.checkbindphone',
                            type: 'post',
                            dataType: 'json',
                            success: function (data) {
                                if(data.Phone){
                                    _ThisPage.Page.TaskList.TaskReceive(Task.Task_ID, Task.Task_Mode, Task.Task_Date);
                                }else{
                                    _ThisPage.Page.CommonUitls.Tip("请先<a href='/member/user/security' target='_blank'>绑定手机</a>,才可以领取任务奖励哦~",{autoclosed:false});
                                    return;
                                }
                            }
                        });
                    });
                },
                //任务领取
                TaskReceive:function (Task_ID, Task_Mode, Task_Date) {
                    $.ajax({
                        url: '/ajax/user.user-task.update-receive',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            ID: Task_ID,// null 任务ID(任务列表里返回)
                            Mode: Task_Mode, //任务模式(任务列表里返回)
                            Date: Task_Date //任务时间(任务列表里返回)
                        },
                        success: function (data) {
                            Log.Out("领取任务，结果：", data);
                            // if (data.flag !== 0) {
                            //     _ThisPage.Page.CommonUitls.Tip(data.msg);
                            //     return;
                            // }
                            if (data.flag === 0) {
                                _ThisState.removeClass("execute").addClass("finish").text("已领取")
                            }
                        }
                    });
                }
            },
            Game:{
                RotateState:false,
                Lottery:function(){
                    $('[data-game="game-rotate"]').on("click",function(){
                        if($("#J_GameRotateC").length>0){
                            return;
                        }
                        $.ajax({
                            url: '/activity/game/rotate',
                            type: 'get',
                            dataType: 'html',
                            success: function (data) {
                                $("body").append(data);
                                _ThisPage.Page.Game.RotateState=true;
                            }
                        });
                    })
                }
            }
        }
    };

    var _PageReSize = {
        MediaSizeChange:function () {
            var _MediaSize = {};
            _MediaSize.height = $(window).height();
            if(_MediaSize.height >= 806){
                $("#J_SideBar").css({
                    "height":"100%"
                });
                $('.MR-Chat').height("");
                $('.WebChatList').height("");
                $('#J_GiftBoxArea').css({
                    "margin-top":""
                });
                $("#J_SideBar").css({
                    "height":""
                });
                $(".RankList").height("");
                $("#J_GiftHistoryListDiv").css({
                    "height":""
                });
                $(".alink").css({
                    "height":"",
                    "line-height":""
                });
            }else{
                $('.MR-Chat').height("564px");
                $('.WebChatList').height("326px");
                $('#J_GiftBoxArea').css({
                    "margin-top":"6px"
                });
                $("#J_SideBar").css({
                    "height":"670px"
                });
                $(".RankList").height("214px");
                $("#J_GiftHistoryListDiv").css({
                    "height":"27px"
                });
                $(".alink").css({
                    "height":"40px",
                    "line-height":"40px"
                });
            }
        }
    };
    _PageReSize.MediaSizeChange();
    $(window).resize(function(){
        _PageReSize.MediaSizeChange();
    });

    $.CommonMainRoom.fnInit({
        SocketURL: _VirtualPath.Socket + 'room',
        // SocketURL: 'www.x.xiutv.com/room',
        RoomID: _PageData.RoomID,
        //
        onConnect: function () {
            Log.Out("onConnect");
        },
        onJoin: function (data) {
            Log.Out("onJoin", data);
            _ThisPage.Page.JoinComplete(data);
        },
        onJoinBroadcast: function (data) {
            Log.Out("onJoinBroadcast", data);
            if(data.RoomUserInfo.IsAdmin) return; //官方 进房信息 其他人不显示
            _ThisPage.Page.Chat.RoomEnterNewUserNotify(data);
        },
        onOutBroadcast: function (data) {
            Log.Out("onOutBroadcast", data);
        },
        onDisconnect:function(){
            _ThisPage.Page.Video.LiveEnd();
            // window.document.location.reload();
        },
        onUserList: function (data) {
            Log.Out("onUserList", data);
            _ThisPage.Page.UserList.Result(data);
        },
        onUserLevelBroadcast: function (data) {
            Log.Out("onUserLevelBroadcast", data);
            _ThisPage.Page.UserLevelUpgrade.AddItem(data);
        },
        onAdminList: function (data) {
            Log.Out("onAdminList", data);
            _ThisPage.Page.UserList.Admin.Result(data);
        },
        onAdminListBroadcast: function (data) {
            Log.Out("onUserLevelBroadcast", data);
            _ThisPage.Page.UserList.Admin.Result(data);
        },
        onLive: function (data) {
            Log.Out("onLive", data);
            _ThisPage.Flash.PublishVideo(data);
            _ThisPage.Page.Video.GetRecommend(false);
            _ThisPage.Page.Video.ActivityLink(true);
            // _ThisPage.Page.RobotManage.SetShowStatus(true);
            if($.CommonMainRoom.RoomUserInfo.RoomAnchor){
                $("#J_LiveStarSwpBtn").hide();
                $("#J_LiveEndBtn").show();
                _ThisPage.Page.RobotManage.Init();
            }
        },
        onLiveBroadcast: function (data) {
            Log.Out("onLiveBroadcast", data);
            if(data.Type == "LiveEnd-BlockSet"){
                _ThisPage.Flash.EndLive();
                _ThisPage.Page.Video.GetRecommend(true);
                _ThisPage.Page.Video.ActivityLink(false);
                alert("此房间已被冻结！");
                window.document.location = _VirtualPath.Main;
                return ;
            }
            else if(data.Type == "Live"){
                if(data.RoomInfo.Live){
                    _ThisPage.Page.RobotManage.Init();
                    _ThisPage.Flash.PlayVideo(data.RoomInfo);
                    _ThisPage.Page.Video.GetRecommend(false);
                    _ThisPage.Page.Video.ActivityLink(true);
                    // _ThisPage.Page.RobotManage.SetShowStatus(true);
                    if($.CommonMainRoom.RoomUserInfo.RoomAnchor){
                        $("#J_LiveStarSwpBtn").hide();
                        $("#J_LiveEndBtn").show();
                    }
                }else{
                    _ThisPage.Flash.EndLive();
                    _ThisPage.Page.Video.GetRecommend(true);
                    _ThisPage.Page.Video.ActivityLink(false);
                    // _ThisPage.Page.RobotManage.SetShowStatus(false);
                    if($.CommonMainRoom.RoomUserInfo.RoomAnchor){
                        $("#J_LiveStarSwpBtn").show();
                        $("#J_LiveEndBtn").hide();
                    }
                }
            }
            else if(data.Type == "LiveEnd" || data.Type == "LiveEnd-Disconnect"){
                _ThisPage.Page.Video.LiveEnd();
            }
        },
        onRunwayBroadcast: function (data) {
            Log.Out("onRunwayBroadcast", data);
            _ThisPage.Page.Runway.AddRunway(data);
        },
        onGuardian: function (data) {
            Log.Out("onGuardian", data);
            _ThisPage.Page.Guardian.BuyResult(data);
            if($("#J_EmoGuardPanel").length>0) $("#J_EmoGuardPanel").remove();//删除守护表情 购买按钮
        },
        onGuardianBroadcast: function (data) {
            Log.Out("onGuardianBroadcast", data);
            _ThisPage.Page.Guardian.BuyResult(data);
        },
        onGift: function (data) {
            Log.Out("onGift", data);
            _ThisPage.Page.Gift.Data.sending = false;
            _ThisPage.Page.Gift.RoomGiftGiveResult(data);
            _ThisPage.Page.Gift.ShowGiftBtnAnimation();
        },
        onGiftBroadcast: function (data) {
            Log.Out("onGiftBroadcast", data);
            _ThisPage.Page.Gift.RoomGiftGiveResult(data);
        },
        onHorn: function (data) {
            Log.Out("onHorn", data);
            if( "ROOM" === data.HornInfo.Mode ){
                _ThisPage.Page.FlyScreen.ShowEffect(data);
            }
        },
        onHornBroadcast: function (data) {
            Log.Out("onHornBroadcast", data);
            if( "ROOM" === data.HornInfo.Mode ){
                _ThisPage.Page.FlyScreen.ShowEffect(data);
            }else if ( "SERVER" === data.HornInfo.Mode ){
                _ThisPage.Page.Horn.ShowEffect(data);
            }
        },
        onPomeloGet: function (data) {
            Log.Out("onPomeloGet", data);
            _ThisPage.Page.PomeloUtil.UpdateSelfPomeloNum(data);
        },
        onPomeloPresent: function (data) {
            Log.Out("onPomeloPresent", data);
            _ThisPage.Page.PomeloUtil.ShowPomeloHistoryList(data);
        },
        onPomeloPresentBroadcast: function (data) {
            Log.Out("onPomeloPresentBroadcast", data);
            _ThisPage.Page.PomeloUtil.ShowPomeloHistoryList(data);
        },
        onMessage: function (data) {
            Log.Out("onMessage", data);
            _ThisPage.Page.Chat.Data.MsgObj.User1 = _ThisPage.Page.Chat.GetMsgUserFormat(data.RoomUserInfo);//以服务器返回的用户数据为准。
            _ThisPage.Page.Chat.ChatShowMsg(_ThisPage.Page.Chat.Data.MsgObj);
        },
        onMessageBroadcast: function (data) {
            Log.Out("onMessageBroadcast", data);
            _ThisPage.Page.Chat.ChatServerMsgReceive(data);
        },
        onAdminSet: function(data){
            Log.Out("onAdminSet", data);
            _ThisPage.Page.CommonUitls.UserRoleTip(data, "Admin");
        },
        onAdminSetBroadcast: function(data){
            Log.Out("onAdminSetBroadcast", data);
            _ThisPage.Page.CommonUitls.UserRoleTip(data, "Admin");
        },
        onBlackSet: function(data){
            Log.Out("onBlackSet", data);
            _ThisPage.Page.CommonUitls.UserRoleTip(data, "Black");
        },
        onBlackSetBroadcast: function(data){
            Log.Out("onBlackSetBroadcast", data);
            _ThisPage.Page.CommonUitls.UserRoleTip(data, "Black");
        },
        onBlockSet: function(data){
            Log.Out("onBlockSet", data);
        },
        onChangeCDN: function(data){
            Log.Out("onChangeCDN", data);
            if($.CommonMainRoom.RoomInfo.Live && $.CommonMainRoom.RoomUserInfo.RoomAnchor){
                _ThisPage.Page.Video.Data.IsChangeCdn = true;
                _ThisPage.Page.Video.CommonUtils.LiveEndEvent();
            }
        },

        onLottery:function (data) {
            Log.Out("onLottery", data);
            if(_ThisPage.Page.Game.RotateState){
                GameLotteryResult("onLottery",data);
                GameLotteryResultShow("onRoomLottery",data);
            }
        },
        onLotteryBroadcast:function(data){
            Log.Out("LotteryBroadcast", data);
            if(_ThisPage.Page.Game.RotateState){
                if(data.RoomUserInfo.User_ID != $.CommonMainRoom.RoomUserInfo.User_ID){
                    GameLotteryResultShow("LotteryBroadcast",data);
                }
            }
        },
        //
        fnRoomInfo: function (data) {
            // Log.Out("---RoomData---", [
            //     {"$.CommonMainRoom.RoomInfo":$.CommonMainRoom.RoomInfo},
            //     {"$.CommonMainRoom.RoomAnchorInfo":$.CommonMainRoom.RoomAnchorInfo},
            //     {"$.CommonMainRoom.RoomUserInfo":$.CommonMainRoom.RoomUserInfo}]);
            Log.Out("fnRoomInfo", data);
            _ThisPage.Page.Room.UpdateInfo(data);
        },
        fnRoomUserInfo: function (data) {
            Log.Out("fnRoomUserInfo", data);
            _ThisPage.Page.Self.UpdateInfo(data);
        },
        fnRoomAnchorInfo: function (data) {
            Log.Out("fnRoomAnchorInfo", data);
            if(data.RoomID != _PageData.RoomID) return; //不是本房间的艺人信息，就拦截，不要更新。
            _ThisPage.Page.Anchor.UpdateInfo(data);
        },
        fnRoomGiftPond: function (data) {
            Log.Out("fnRoomGiftPond", data);
            _ThisPage.Page.PondBroadcast(data);
        },
        fnRoomGuardian: function (data) {
            Log.Out("fnRoomGuardian", data);
            _ThisPage.Page.Guardian.UpdateNotify(data);
        },
        fnBlackJoin: function (data) {
            _ThisPage.Flash.EndLive();
            alert(data);
            window.document.location = _VirtualPath.Main;
        },
        fnErrorNotEnough: function (data) {
            Log.Out("fnErrorNotEnough", data);
            _ThisPage.Page.Gift.Data.sending = false;
            _ThisPage.Page.CommonUitls.PayBoxPanel.Show();
            GameLottery_Notice(data);
        },
        fnErrorOther:function(data){
            Log.Out("fnErrorOther", data);
            _ThisPage.Page.Gift.Data.sending = false;
            _ThisPage.Page.CommonUitls.Tip("Error " + data.message + "(" + data.flag + ")");
        },
        fnUserPackage:function (data) {
            Log.Out("fnUserPackage", data);
            _ThisPage.Page.Gift.UpdateUserPackage(data);
        }
    });

    //直播间页面初始化
    _ThisPage.Page.Init();

});
////////////////////////////////////
//黑名单设置
//id:被操作人ID
//type:操作类型 1：禁言，2：踢人，3：取消禁言，4：取消踢人
//mode:禁言或踢人,的类型，["NEVER", "YEAR", "MONTH", "WEEK", "DAY", "HOUR", "MINUTE"]
//value:操作类型 禁言或踢人的时间值
////////////////////////////////////